# PersistentRecord setString not updating value

**URL:** <https://forum.inductiveautomation.com/t/persistentrecord-setstring-not-updating-value/45288>\
**Category:** Module Development\
**Created:** [April 5, 2021, 11:50pm UTC](https://forum.inductiveautomation.com/t/persistentrecord-setstring-not-updating-value/45288 "2021-04-05T23:50:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [April 5, 2021, 11:50pm UTC](https://forum.inductiveautomation.com/t/persistentrecord-setstring-not-updating-value/45288/1 "2021-04-05T23:50:06Z")

</div>

I am updating the following value on a persistent record to maintain the status of an object:

```auto
public static final StringField Status = new StringField(META, "Status", SFieldFlags.SMANDATORY, SFieldFlags.SDESCRIPTIVE).setDefault("Created");

public void setStatus(String status) {
        logger.debug("Setting status for " + this.getName() + " to " + status);
        this.setString(Status, status);
    }

```

And am calling it in the following way:

```auto
List<BaseRecord> baseRecords = context.getPersistenceInterface().query(new SQuery<>(BaseRecord.META));
for (BaseRecord SettingsRecord : baseRecords) {
    DatabaseConnector connector = gateway.getConnector(SettingsRecord.getName());
    boolean isConnected = connector.verifyConnectivity();
    boolean enabled = SettingsRecord.getBoolean(BaseRecord.Enabled);

    String status = (isConnected) ? "Valid" : "Faulted";
    status = (enabled) ? status : "Disabled";
    SettingsRecord.setStatus(status);
}

```

And I can see in the logs where my code is trying to update the statuses:

 ![Screen Shot 2021-04-05 at 4.49.15 PM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/1/2177be51c3210b68783942baeb42b307ea7df995.png)

But for some reason they are never updating. I tested it out by making the value visible in the config form and updating it manually to “TEST” and I don’t ever see it change from that value, even with the logs saying it should.

---

<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:** [April 5, 2021, 11:58pm UTC](https://forum.inductiveautomation.com/t/persistentrecord-setstring-not-updating-value/45288/2 "2021-04-05T23:58:25Z")

</div>

You need to actually call into the ORM to persist your changes to the object. You can probably just use:  
`context.getPersistenceInterface().save(SettingsRecord);`  
As the last line in your loop.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [April 5, 2021, 11:59pm UTC](https://forum.inductiveautomation.com/t/persistentrecord-setstring-not-updating-value/45288/3 "2021-04-05T23:59:58Z")

</div>

> [@paul-griffith](#):
>
> context.getPersistenceInterface().save(SettingsRecord);

This was exactly what I needed! Thanks Paul
