Skip to main content
Nintex Community Menu Bar
Question

unable to clear field values after unrendering

  • July 10, 2024
  • 7 replies
  • 19 views

Forum|alt.badge.img+2

Hi,

I have a picklist field Test_a which is rendered with Test_b and Test_c
when Test_a is set to Yes then it will display the fields Test_b and Test_c,
but when I select Test_a as No I can still see the data for Test_b and Test_c in the database, when I set Test_a back to Yes the data is still there under Test_b and Test_c

Is there any way where I can clear the data when the fields are not rendered.

Please let me know if there is any JS or easy workaround.

Thanks in advance!




 

7 replies

Forum|alt.badge.img+9

Did you set the Render property to “If hidden, Model field changes should be…Cancelled

The default setting is “Retained in Model”…which means even after un-rendering, the data stored in those fields would be Retained in the Model, and thus saved to the server on the save action.


Forum|alt.badge.img+2
  • Author
  • July 10, 2024

Yes Conlan, I did set the value to ‘Cancelled’
but I can still see the data


Forum|alt.badge.img+18

If the data for the hidden fields is already saved in salesforce, you’ll have to run actions to update the values of those fields to {{blank}}.

Here’s one solution:

Use a model action that runs when Test_a changes. The action framework sequence should:

  1. Use a branch to check if Test_a is ‘No’. if it is, then
  2. update field on row: Test_b = {{blank}}
  3. update field on row: Text_c = {{blank}}


Forum|alt.badge.img+2
  • Author
  • July 10, 2024

Hi Matt,

Could you be more specific regarding the below point

  1. Use a branch to check if Test_a is ‘No’. if it is, 
Thanks much


Forum|alt.badge.img+2
  • Author
  • July 10, 2024

Sorry it worked… but it is not saving the data back to database, am I doing something wrong?


Forum|alt.badge.img+18

If you want it to save automatically, just add a save action to the end of the sequence.


Forum|alt.badge.img+2
  • Author
  • July 10, 2024

Hi Matt,

it was not saving the data, even after including the save action.

I had included JS for the save button and its working perfectly

var params = arguments[0],    $ = skuid.$;

var myModel = skuid.$M(‘Test’);
var rowsToUpdate = {};
var rows = myModel.getRows();

$.each(rows, function(i, row) {
    if (row.Test_a__c == ‘No’) {
        rowsToUpdate[this.Id] = {
            Test_b__c: false,
            Test_b__c: false
        };
    }
});

myModel.updateRows(rowsToUpdate);