# Refreshing Form After Save

**URL:** <https://www.five.org/t/refreshing-form-after-save/631>\
**Category:** How do I?\
**Created:** [March 24, 2026, 8:15pm UTC](https://www.five.org/t/refreshing-form-after-save/631 "2026-03-24T20:15:30Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![RMittelman](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/rmittelman/32/447_2.png) [@RMittelman](https://www.five.org/u/RMittelman)\
**Post date:** [March 24, 2026, 8:15pm UTC](https://www.five.org/t/refreshing-form-after-save/631/1 "2026-03-24T20:15:30Z")

</div>

I have a new table and form, both called **Settings**. This is to replace setting some variables in code in my **InitialSetup** function. Table fields are **SettingName** , **SettingType** and **SettingValue**.

**SettingType** is a combo on the form with possible values **Text** , **Number** , **Boolean** and **JSON**.

**SettingValue** stores the actual value as text, regardless of type. it is a Memo field.

I also have user fields for each type of setting. These are initially hidden, and each one is shown depending on SettingType. So if **SettingType** is JSON, then the **SettingJson** text control (also a Memo) is displayed.

When a record is shown, the **InitSettingValue** function runs. part of what it does is load the SettingValue into the appropriate visible control. So for JSON, it basically does a pretty-print of the JSON value into the **SettingJson** unbound field.

This works fine on the initial load, but I’m having trouble getting it to work after the field (or record) is saved.

I put **InitSettingValue** in the new **On Finish** event for the form. I was told this event would fire AFTER the record was saved. As you may remember, the **On Complete** event actually fires before the record is saved, and prevents the actual saving of the record.

What I expected to happen is that when I change the text of **SettingValue** , then save the form record, it should redisplay the **SettingJson** field, including any changes made to **SettingValue**. This is not happening.

I must actually move to another record, then move back to see the formatted changes in **SettingJson**.

Is there a way to refresh the form data via code?  
Is the **On Finish** event not firing as expected?

My original intent was to call code in the **On Validate** event immediately after changing the field value to refresh the visible field. But that won’t work either.

Can you suggest a way to make this work?

Thanks…

---

<div class="post-metadata">

**Author:** ![RMittelman](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/rmittelman/32/447_2.png) [@RMittelman](https://www.five.org/u/RMittelman)\
**Post date:** [March 25, 2026, 8:20pm UTC](https://www.five.org/t/refreshing-form-after-save/631/2 "2026-03-25T20:20:57Z")

</div>

Thanks, but this is mostly solved. My validate code had some issues.

Even without anything in the **On Finish** event, it now works mostly. The **On Validate** function attempts to parse the json, and if it passes, it automatically re-displays the **SettingsJson** field with prettified data, and also replaces the **SettingsValue** with stringified non-pretty value. this is the one that’s stored in the database.

Since this happens in the **On Validate** function, I don’t need to re-display the info when saving the record.

What’s not working: If I’ve changed the field value, and can’t get it right, I hit the cancel X button, which should also fire **InitSettingValue** , thus refreshing the **SettingsJson** prettified value from the original **SettingsValue** field. This is not happening. It just cancels the update, but doesn’t re-display the data properly.

Thanks…

---

<div class="post-metadata">

**Author:** ![eltonsantos](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@eltonsantos](https://www.five.org/u/eltonsantos)\
**Post date:** [March 30, 2026, 3:17am UTC](https://www.five.org/t/refreshing-form-after-save/631/3 "2026-03-30T03:17:00Z")

</div>

Hi Ron,

Thank you for letting me know that this functionality is partially working.

Just to clarify it, the event **On Finish** was not designed to change the value from the same form, as it does not trigger the backend with all necessary states. One example of how you can use it is, after saving a form, you could programmatically navigate to another menu using this event.

Regarding your question: If you meant the **cancel X button** on the form field, the only event that triggers a function is the ‘On Click‘, because you are still clicking on the field.

Regards,  
Elton S

---

<div class="post-metadata">

**Author:** ![RMittelman](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/rmittelman/32/447_2.png) [@RMittelman](https://www.five.org/u/RMittelman)\
**Post date:** [March 30, 2026, 5:54pm UTC](https://www.five.org/t/refreshing-form-after-save/631/4 "2026-03-30T17:54:31Z")

</div>

Thanks for the answer Elton. I thought the On Finish would be able to modify an unbound field value, as it’s not being written back to the database.

I was referring to the main cancel button on the form. I want to cancel an update or change I was trying to make to a field or fields on the form.

There is an **On Cancel** event available, which I interpret to mean that this event fires when I click the **X** at the top right of the form, next to the save checkmark. I put **InitSettingValue** in the **On Cancel** event during form design. This function should take what is in the **SettingValue** field and prettify it in the unbound **SettingJson** field.

The intent on this form is to have the **SettingValue** field hidden. This is a bound field to the same-named field in the table. The edit should be done in the visible **SettiingJson** field. For now, I’m keeping the **SettingValue** field visible during development.

Can you tell me why the function is not restoring the proper value into the SettingJson field? Thanks…

---

<div class="post-metadata">

**Author:** ![eltonsantos](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@eltonsantos](https://www.five.org/u/eltonsantos)\
**Post date:** [March 30, 2026, 10:08pm UTC](https://www.five.org/t/refreshing-form-after-save/631/5 "2026-03-30T22:08:51Z")

</div>

Hi Ron,

The **On Cancel** button on the form will be triggered when you click the **X** button on the **main form** ; this will close/cancel the current form edition, and return the field values to the latest data saved in the table when you accessed the form.

If you are using this function to change another form’s field, it won’t work because it will discard all the changes and remove the form from edit mode.

In case it could help you, as I don’t know your case scenario:  
You could perhaps add a field not bound to the table, with a display-type button, and add a function to reset a field value.

Regards,  
Elton S

---

<div class="post-metadata">

**Author:** ![RMittelman](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/rmittelman/32/447_2.png) [@RMittelman](https://www.five.org/u/RMittelman)\
**Post date:** [March 30, 2026, 11:54pm UTC](https://www.five.org/t/refreshing-form-after-save/631/6 "2026-03-30T23:54:36Z")

</div>

Well, thanks so much for the quick reply.

The Settings table / form have 3 fields:  
SettingName (text 50),  
SettingType: (drop-down: Boolean, Text, Number, JSON),  
SettingValue: (memo)

The form also has 4 unbound fields, one for each type. The SettingBool is a checkbox, the SettingText is a memo, SettingNumber is a text field and SettingJson is memo. These each become visible based on SettingType.

The idea is to make the entries in the unbound fields, then the validate event will make sure the text is correct, and store the value in the SettingsValue bound field. In the case of JSON, the validate event should also pretty-print it back to that field, and stringify it to the value field.

I was hoping the cancel button would call the InitSettingValue function which would simply re-display the prettified JSON in that field. Also, I had hoped the On Finish event would also be able to redisplay the unbound field prettified.

---

<div class="post-metadata">

**Author:** ![RMittelman](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/rmittelman/32/447_2.png) [@RMittelman](https://www.five.org/u/RMittelman)\
**Post date:** [April 13, 2026, 7:09pm UTC](https://www.five.org/t/refreshing-form-after-save/631/7 "2026-04-13T19:09:24Z")

</div>

It’s been about 2 weeks with no answer on this topic.

When I open my Settings form and pick a setting from the list, the **On Show** event runs the **InitSettingValue** function, which, given the setting type, makes the appropriate unbound field visible, then loads it from the bound **SettingValue** field, which will be hidden after development. In the case of SettingType of “JSON”, this means it pretty-prints the json object into the field. This works fine.

All changes will be made to the visible unbound field, and the **On Validate** event will cause the JSON (or whatever) value to be verified, then stringified into the **SettingValue** field.

This is working properly. However, if I made a change to the JSON which will not validate, then I click the Cancel X button, this is also set to run the **InitSettingValue** function. But in this case, it does not really work. the incorrect JSON value is not “fixed” and redisplayed (pretty) in the unbound field. My changes are indeed cancelled, and if I move to another setting and back, it will be properly displayed in the unbound field.

The question is, why doesn’t the **InitSettingValue** function cause the field to be properly refreshed after a Cancel??

Here is pertinent code:

```auto
function InitSettingValue(five, context, result) {
five.log('InitSettingValue');
    const raw = five.field.SettingValue || '';
    const fieldType = (five.field.SettingType || '').toLowerCase();
    let fieldName;

    // reset all user-facing fields first
    five.field.SettingJson = '';
    five.field.SettingText = '';
    five.field.SettingNumber = '';
    five.field.SettingBool = false; // checkbox → default false

    // now populate based on type
    if (fieldType === 'json') {
        fieldName = 'SettingJson';
        try {
            five.field[fieldName] = raw ? JSON.stringify(JSON.parse(raw), null, 2) : '';
            // five.field.SettingJson = raw ? JSON.stringify(JSON.parse(raw), null, 2) : '';
        } catch (e) {
            five.field[fieldName] = raw;
            // five.field.SettingJson = raw;
            // const msg = 'For JSON, Item names and text values must use double quotes.\n ex: {"Item": value (or "value"),...} \n\nArrays must use double quotes if text\n. ex: [Item, Item...] (or ["Item", "Item",...])';
            // five.log(raw);
            // MessageBox(five, {Title: "Invalid Value", Message: msg});
        }
        ShowSettingField(five, fieldName, fieldType);
    }

```

Here is the pertinent snippet of the library code:

```auto
function ShowSettingField(five, fieldName, fieldType) {
    
    // display properly formatted field data
    
    const raw = five.field.SettingValue || '';
    const fType = (fieldType || '').toLowerCase();
    five.log(`ShowSettingField: fieldName=${fieldName}, fType=${fType}`);
    five.field[fieldName] = '';
    switch (fType) {
        case 'json':
            try {
                five.field[fieldName] = raw ? JSON.stringify(JSON.parse(raw), null, 2) : '';
                five.log('ShowSettingField: set field value pretty')
            } catch (e) {
                five.field[fieldName] = raw;
                five.log(`ShowSettingValue: error ${e.message}`);
            }
            break;

```

Thanks…

---

<div class="post-metadata">

**Author:** ![eltonsantos](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@eltonsantos](https://www.five.org/u/eltonsantos)\
**Post date:** [April 14, 2026, 6:17am UTC](https://www.five.org/t/refreshing-form-after-save/631/8 "2026-04-14T06:17:26Z")

</div>

Hi Ron,

The **On Show** event is not triggered when clicking on the Cancel X button.

When you click on the Cancel X button, the fields should return to their initial state value. Can you confirm that is the case, what is teh default value when you first navigate to teh form?

What you may be able to do is, when you click on the cancel button, you programmatically click on the edit button and change the value. I think you have done it before.

I will check if I have any functionality that may help you, but I cannot guarantee it, as it is likely to be custom development.

Regards,  
Elton S

---

<div class="post-metadata">

**Author:** ![RMittelman](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/rmittelman/32/447_2.png) [@RMittelman](https://www.five.org/u/RMittelman)\
**Post date:** [April 14, 2026, 5:12pm UTC](https://www.five.org/t/refreshing-form-after-save/631/9 "2026-04-14T17:12:12Z")

</div>

Thanks for the quick answer, but I don’t think you understood my question. Sorry if I wasn’t clear.

I mentioned **On Show** only because that event is triggering a function that takes the actual bound field and puts its contents into an unbound field, in this case, it pretty-prints the JSON into the unbound field. This function is **InitSettingValue**.

I also call that function from the **On Cancel** event. My expectation was that calling the function from On Cancel would cause the not-yet-changed bound field to be redisplayed “prettified” in the unbound field (the same as it is when first showing the record). Remember I’m making the actual edit in the unbound field.

---

<div class="post-metadata">

**Author:** ![eltonsantos](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@eltonsantos](https://www.five.org/u/eltonsantos)\
**Post date:** [April 15, 2026, 9:47pm UTC](https://www.five.org/t/refreshing-form-after-save/631/10 "2026-04-15T21:47:10Z")

</div>

Hi Ron,

Can you please share a version of the application with this current setting, as well as simple steps to reproduce it, so I can better investigate it?

Regards,  
Elton S

---

<div class="post-metadata">

**Author:** ![RMittelman](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/rmittelman/32/447_2.png) [@RMittelman](https://www.five.org/u/RMittelman)\
**Post date:** [April 15, 2026, 10:50pm UTC](https://www.five.org/t/refreshing-form-after-save/631/11 "2026-04-15T22:50:27Z")

</div>

Hi Elton,

Here is the FDF file:  
[BrandeisConejo-20260415-22313555653284.fdf](https://www.five.org/uploads/short-url/ceZ8nLnc7VMksKahBdxSFkSgWQK.fdf) (6.8 MB)

Open the application with the Control credential I gave you, then deploy and run the application with the Admin credential I gave you.

With application running, go to Setup\>Settings. Pick any particular setting, such as Colors. you should see this:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/five/original/2X/e/e96f15e831c8978937762c9bc46e9d303dcc69aa.png)  
Please note, the **Setting Value (bound)** text box is not where you make the entry, but instead in the **SettingValue (json)** text box. The lower text box will be hidden once the application is working.

Go into edit mode, and right after the opening **{** , type the word **Test**.

Click anywhere else on the form and you will se a message showing that you did not type in valid JSON text.

Click the **X** in upper-right of the form to cancel the edit. You will notice that the edit is in fact cancelled, but the **SettingValue (json)** text box still contains the word “Test”.

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/five/original/2X/d/dd4db37c093dcabbd579e097712f9346d3149729.png)

If you look at the form in design mode, you’ll notice that **On Show** and **On Cancel** both should run the **InitSettingValue** function. This function should take the (still correct) **Setting Value (bound)** value and pretty-print it into the **SettingValue (json)** field.

This does not happen, even though On Cancel is calling the same function. To fix this, you need to move to another record then back again. This time, the value is correct in the upper text box.

I guess this has something to do with it being an unbound field, but I’m not sure. I thought that calling the init function there from the On Cancel event would re-display the JSON properly.

Thanks…

---

<div class="post-metadata">

**Author:** ![eltonsantos](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@eltonsantos](https://www.five.org/u/eltonsantos)\
**Post date:** [April 21, 2026, 5:18am UTC](https://www.five.org/t/refreshing-form-after-save/631/12 "2026-04-21T05:18:39Z")

</div>

Hi Ron,

Thank you for sharing your application.

As mentioned, the event **On Cancel** won’t work in this scenario because this event was not designed to modify form field values.

The **On Cancel** event would work if the field is bound to the database and the data is already saved in that field when accessing the record; So, the latest values stored in the DB will be restored to the field when cancelling teh changes.

What you could do is:

When you detect that the information is invalid, instead of using five.createError, you could use **five.confirm** and ask the user if he wants to retrieve the data, then call your function that puts the data back. However, in your current code, it won’t work because once the format is wrong, you clean the field ‘Settings Value (Bound)’, and this field sends the data to the field ‘SettingValue JSON’. (If I understood your logic)

This link has an example on how to use **five.confirm** in case it helps you.

[Delete and Edit not Working Properly - How do I? - Five | Community Forum](https://www.five.org/t/delete-and-edit-not-working-properly/560/24)

Regards,  
Elton S

---

<div class="post-metadata">

**Author:** ![RMittelman](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/rmittelman/32/447_2.png) [@RMittelman](https://www.five.org/u/RMittelman)\
**Post date:** [May 6, 2026, 11:05pm UTC](https://www.five.org/t/refreshing-form-after-save/631/13 "2026-05-06T23:05:01Z")

</div>

Can you please clarify this answer? Does OnCancel not work on form fields that are unbound? I understand it may not work on bound fields.

My **Settings** form calls the **InitSettingValue** function, which basically takes the bound **SettingValue** field value and puts it into the **SettingJson** field pretty-printed if the setting type was “JSON”.

I call the InitSettingValue function from OnShow and OnCancel events. It seems to work fine from OnShow, but not from OnCancel. Seems like it should work from both places.

Scenario: I go into a setting that uses JSON. The SettingJson field shows the pretty version of the value in the SettingValue field. I go to change the SettingJson field. If I’ve changed it properly (still valid), the validate event causes the pretty json value to be parsed then stringified into the SettingValue bound field. Then the record gets saved.

If the SettingJson value is bad, I get an error then control is returned to the SettingJson field so I can correct it. but if it is too malformed and I don’t know how to fix it, I hit the cancel button and the original setting value is unchanged. but the SettingJson field isn’t refreshed back to what it should be.

If I leave the record then come back, it works properly. I’m wondering if calling a function from OnCancel causes a problem. I remember we had an issue where if I ran a function from OnComplete event, it actually prevented the save happening on the server. Could that be happening here?

**Bottom line question: Does using OnCancel prevent any fields from being updated via code, or only bound fields? If so, how can I refresh the SettingJson field (which is not bound) after I cancelled an edit?**

thanks…

---

<div class="post-metadata">

**Author:** ![eltonsantos](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@eltonsantos](https://www.five.org/u/eltonsantos)\
**Post date:** [May 7, 2026, 2:07am UTC](https://www.five.org/t/refreshing-form-after-save/631/14 "2026-05-07T02:07:43Z")

</div>

Hi Ron,

At the moment, the event **OnCancel** is not designed to chnage form field values.

Instead of using the cancel button, try to add a button to the form and only display it if teh format is incorrect, then when clicking on this button, you can call the function to change the value in teh field.

Otherwise, have you tried the workaround solution I mentioned in my past response?

Additionally, I have attached a sample app, where you select a record, the field ‘ **Total**  **Price** ’ will be automatically populated by the event **On Show** , and if you try to change the value of this, I have a validation that if it fails, a new button will be displayed so you can reset the form using the same function executed in the event **On Show**.

Please let me know how that goes.

Regards,

Elton S

[RestoreValueApp-20260507-0202537236209\_ForRon.fdf](https://www.five.org/uploads/short-url/okpwH9OQquN2KeQHJYFyquXXiYC.fdf) (3.4 MB)

---

<div class="post-metadata">

**Author:** ![RMittelman](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/rmittelman/32/447_2.png) [@RMittelman](https://www.five.org/u/RMittelman)\
**Post date:** [May 7, 2026, 5:23pm UTC](https://www.five.org/t/refreshing-form-after-save/631/15 "2026-05-07T17:23:40Z")

</div>

Thanks for the quick reply. I will look into doing that solution. This is probably fairly low priority, because if I leave the record and come back to it, everything is displayed properly again.

---

<div class="post-metadata">

**Author:** ![RMittelman](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/rmittelman/32/447_2.png) [@RMittelman](https://www.five.org/u/RMittelman)\
**Post date:** [May 26, 2026, 11:05pm UTC](https://www.five.org/t/refreshing-form-after-save/631/16 "2026-05-26T23:05:57Z")

</div>

UPDATE:

I have gotten this working by simplifying the form. I was using one bound field and several unbound fields to show formatted data, depending on setting type. This was a nightmare.

I revamped the table to include fields for each setting type, such as “SettingJson”, “SettingText”, “SettingNumber” and “SettingBool”, then populated them based on the data in the “SettingValue” field.

Then I modifed the form to set all of those fields to bound by giving them a field ID from the table. Now it all works properly, and simplifies the code.

---

<div class="post-metadata">

**Author:** ![eltonsantos](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@eltonsantos](https://www.five.org/u/eltonsantos)\
**Post date:** [May 26, 2026, 11:43pm UTC](https://www.five.org/t/refreshing-form-after-save/631/17 "2026-05-26T23:43:46Z")

</div>

Hi Ron,

Thank you for the update. I’m glad to hear you found a solution.

Regards,  
Elton
