# Why Ignition module automatically update the initial record

**URL:** <https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127>\
**Category:** Module Development\
**Tags:** database\
**Created:** [June 28, 2020, 8:02pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127 "2020-06-28T20:02:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhouhcupb](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zhouhcupb/32/16095_2.png) [@zhouhcupb](https://forum.inductiveautomation.com/u/zhouhcupb)\
**Post date:** [June 28, 2020, 8:02pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127/1 "2020-06-28T20:02:32Z")

</div>

Hi everyone,

I create a demo module which will create an initial record at the `setup` procedure.

But when I want to add new record, I find that the initial record will automatically updated.

For example, the initial record I create is “HomeConnect Hub” at the `setup` procedure.  
But if I add a new record which is “NEW CREATED”, the initial record will be updated to “NEW CREATED”.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/f/7fdecbe1b2266f1f9cedf424328a7af8596bd8a1.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/4/94b457e53ae6b004d9c1aa9f2b90dcb7456d7967.png)

So my questions are:  
1.Is there a way to avoid updated the initial record?  
2.I tried not to create the initial record at first time, but then run into an internal error. Why does that happen?  
I think the initial record is necessary but I do not know the reason.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 29, 2020, 3:12pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127/2 "2020-06-29T15:12:12Z")

</div>

Any `PersistentRecords` (and thus, tables in the internal DB) required for your module to run should be created in your modules `GatewayHook#setup()` by calling [`GatewayContext.getSchemaUpdater().updatePersistentRecords()`](https://github.com/inductiveautomation/ignition-sdk-examples/blob/master/gateway-webpage/gateway-webpage-gateway/src/main/java/com/inductiveautomation/ignition/examples/hce/GatewayHook.java#L162)

What it does after that is attempt to create a ‘singleton’ instance of the Home Connect record, in the [`maybeCreateHCSettings`](https://github.com/inductiveautomation/ignition-sdk-examples/blob/7881f39b9662a5936758fa2a129e1f000fdf0141/gateway-webpage/gateway-webpage-gateway/src/main/java/com/inductiveautomation/ignition/examples/hce/GatewayHook.java#L168) method. What modifications did you make to this example? The `0L` primary key is the important part; it’s always referring to records by the `HCSETTINGSRECORD_ID`. As the module is written, a default record will be created and any editing on the config page will happen on that single record.

For a slightly different approach - say you want to be able to configure additional devices, you can try the [`secret-keeper`](https://github.com/paul-griffith/secret-keeper/tree/master/gateway/src/main/java/com/griffithindustries/secrets/gateway) module I just wrote up as a proof of concept.  
The [`GatewayHook`](https://github.com/paul-griffith/secret-keeper/blob/master/gateway/src/main/java/com/griffithindustries/secrets/gateway/SecretKeeperGatewayHook.java#L54) ensures the required table exists, but does not create any records.  
Meanwhile, the [`SecretManagerPage`](https://github.com/paul-griffith/secret-keeper/blob/master/gateway/src/main/java/com/griffithindustries/secrets/gateway/SecretManagerPage.java) uses the Ignition API class `RecordActionTable` to create the default CRUD interaction around a `PersistentRecord` implementation - you’ll be able to add new records, update existing ones, etc.

---

<div class="post-metadata">

**Author:** ![zhouhcupb](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zhouhcupb/32/16095_2.png) [@zhouhcupb](https://forum.inductiveautomation.com/u/zhouhcupb)\
**Post date:** [June 29, 2020, 11:45pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127/3 "2020-06-29T23:45:29Z")

</div>

Thanks for your reply sir.  
I will have a deep look into the code. 👍 👍 👍

---

<div class="post-metadata">

**Author:** ![cboin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@cboin](https://forum.inductiveautomation.com/u/cboin)\
**Post date:** [September 8, 2020, 1:25pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127/4 "2020-09-08T13:25:54Z")

</div>

Hi @paul-griffith, could you provide a link to ‘SecretManagerPage’ (the one in your above comment 404’s)? I am trying to implement the RecordActionTable, but cannot figure out how to get it fully working.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 8, 2020, 2:17pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127/5 "2020-09-08T14:17:30Z")

</div>

If you browse [that repository](https://github.com/paul-griffith/secret-keeper), you’ll see that it was renamed.

---

<div class="post-metadata">

**Author:** ![cboin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@cboin](https://forum.inductiveautomation.com/u/cboin)\
**Post date:** [September 8, 2020, 2:31pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127/6 "2020-09-08T14:31:48Z")

</div>

I cannot figure out why, but I am not getting any config panel to show up in my gateway at all. I followed the secret keeper example, but instead created my own config category.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/a/dadaa289ed6059e162f0067ffe44f25ef2d37545.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/6/4612d7a2958c7b78c482eb92e649ab17983d6f6f.png)

Is there something else I need to do in the gateway setup to create the config link?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 8, 2020, 2:49pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127/7 "2020-09-08T14:49:26Z")

</div>

The rest of the module is mounted and running? At a glance your code seems fine. Can you upload your code anywhere, or DM me a built module?

---

<div class="post-metadata">

**Author:** ![cboin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@cboin](https://forum.inductiveautomation.com/u/cboin)\
**Post date:** [September 8, 2020, 3:11pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127/8 "2020-09-08T15:11:30Z")

</div>

Just sent it, the module is in a running state for me… let me know if you need the code, I have it on github but in a private repository… do you do remote support?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 8, 2020, 3:53pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127/9 "2020-09-08T15:53:03Z")

</div>

IA doesn’t do remote support for module development, it’s very much a ‘pursue at your own risk’ endeavor. I’ll usually help people get started “on my own time” because more module authors means more modules means more community engagement 🙂

---

<div class="post-metadata">

**Author:** ![cboin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@cboin](https://forum.inductiveautomation.com/u/cboin)\
**Post date:** [September 8, 2020, 3:56pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127/10 "2020-09-08T15:56:46Z")

</div>

Okay I understand. I will DM you the GatewayHook, SettingsRecord, SettingsPage and corresponding properties files!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 8, 2020, 4:08pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127/11 "2020-09-08T16:08:24Z")

</div>

You’re creating a new `ConfigCategory`, but not returning it in `getConfigCategories()` on your gateway hook:

```auto
default List<ConfigCategory> getConfigCategories() {
        return null;
    }

```

---

<div class="post-metadata">

**Author:** ![cboin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@cboin](https://forum.inductiveautomation.com/u/cboin)\
**Post date:** [September 8, 2020, 4:14pm UTC](https://forum.inductiveautomation.com/t/why-ignition-module-automatically-update-the-initial-record/36127/12 "2020-09-08T16:14:31Z")

</div>

Wow just like that the ConfigCategory popped up. I’ll keep playing around! Thank you for the help.
