Help identifying what changed on form to trigger 'Leave Page' pop-up

Jon23
Mega Sage

Hi, 

I have a scenario where user opens an RITM to view details, then, when navigating away they receive (one of) the following pop-up warning even though the user has not changed anything:

Jon23_0-1738875457112.png 

Jon23_1-1738875554344.png

 

I have been able to replicate the issue (only appears to happen on specific cat item/scenario), however, i am unable to identify what is being changed to trigger the pop-up.

 

  • Audit history shows no changes to field
  • Comparing record XML before and after save show only fields updated: <sys_mod_count>, <sys_updated_by>, <sys_updated_on>
  • Comparing item variables shows no difference.
  • Looking at client on-load scripts has not uncovered anything at this time.

 

Is there any debug method that shows what changed?

1 ACCEPTED SOLUTION

Jon23
Mega Sage

@Mark Manders  - I feel i have gone through all the client scripts/ui policies (100x) that do something onLoad and not found anything... but keep going back as i must of missed something! ...right?

 

@Fumiya_F - I created a UI action based on the script you provided.  No changes found on any of the table fields.

 

What about the form variables? 🤔

Using the following code (sourced: SN Guru - Checking for Modified or Changed Fields in Script ) I was able to confirm that a form variable was reported as changed:

 

alert('Variables Changed: ' + $$('.changed').length);

 

Variables Changed: 1

 

How do I identify which variable was changed? 🤔

I ran the following code in a UI action, which returned a list of all the variables for the item:

function changedFields() {

    alert('Variables Changed: ' + $$('.changed').length);

    var formVars = [];
    var formVarName = '';

    for (var index = 0; index < g_form.nameMap.length; index++) {
        formVarName = "Name Map # " + index + ": " + g_form.nameMap[index].prettyName;
        formVars.push(formVarName);
    }
	
    console.log(formVars.join(' | '));

}

 

I couldn't find a way to use the variables list to search for changed. 

 

🎉How I finally found the variable.... 🎉

Loaded the RITM page withe developer tools running, then, using the elements tab I searched for changed.

Going through each occurrence (only 18 found) and reviewing what else was wrapped around it, the variable was identified:

example of the html code identifying changed:

<label for="my_variable" class="control-label sc_editor_label ">
    <span id="status.ni.VE4d1234553beb5610c1409047f4e45aa4" aria-label="" title="" mandatory="false" oclass=" required-marker" class="changed required-marker label_description" data-original-title="">&nbsp;</span>
    <span class="sn-tooltip-basic " data-toggle="tooltip" data-placement="auto" role="heading" aria-level="3" aria-label="My Variable">My Variable</span>
    <span id="status.button.ni.VE4d1234553beb5610c1409047f4e45aa4" aria-label="" title="" label-title="" tabindex="0" role="button" class="icon-help btn-default" style="display: none;" aria-hidden="true" data-original-title=""></span>
</label>

 

View solution in original post

3 REPLIES 3

Mark Manders
Mega Patron

Check on any client scripts/ui policies that do something onLoad (it could even be something like setting the assignment group (which doesn't actually change in value, but if your client script runs and sets it (again), it will be seen as an update and needs to be saved. Most of the time this is due to not using best practice while scripting.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Fumiya_F
Tera Contributor
Hi Jon
 
g_form.getControl(FieldName).changed
allows you to check which fields on a form have changed.
 
before leaving the screen
Using UI actions or client scripts (onSubmit)
It is recommended that you show the fields that have changed.
 
UI Action example (check with client)================================
function onClick() {
var changeFieldName = "";
 
// get editable items
var fields = g_form.getEditableFields(); 
 
for (var i = 0; i < fields.length; i++) {
var element = g_form.getControl(fields[i]);
// retain edited item name
if(element.changed == true) {
if(changeFieldName == "") {
changeFieldName = fields[i];
} else {
changeFieldName =  changeFieldName + "," + fields[i];
}
}
}
// show edited item name
alert("changeFieldName:" + changeFieldName);
}
==================================================================
The reasons for limiting settings to editable items are as follows:
・For inactive items, even if you change the value
 pop-up is not displayed.
 
What do you think?
Although time has passed, I'm sure there are still some engineers who are worried.
I hope this reply is helpful!
 
If you found this helpful, please press the thumbs up icon to mark it as correct! !

Jon23
Mega Sage

@Mark Manders  - I feel i have gone through all the client scripts/ui policies (100x) that do something onLoad and not found anything... but keep going back as i must of missed something! ...right?

 

@Fumiya_F - I created a UI action based on the script you provided.  No changes found on any of the table fields.

 

What about the form variables? 🤔

Using the following code (sourced: SN Guru - Checking for Modified or Changed Fields in Script ) I was able to confirm that a form variable was reported as changed:

 

alert('Variables Changed: ' + $$('.changed').length);

 

Variables Changed: 1

 

How do I identify which variable was changed? 🤔

I ran the following code in a UI action, which returned a list of all the variables for the item:

function changedFields() {

    alert('Variables Changed: ' + $$('.changed').length);

    var formVars = [];
    var formVarName = '';

    for (var index = 0; index < g_form.nameMap.length; index++) {
        formVarName = "Name Map # " + index + ": " + g_form.nameMap[index].prettyName;
        formVars.push(formVarName);
    }
	
    console.log(formVars.join(' | '));

}

 

I couldn't find a way to use the variables list to search for changed. 

 

🎉How I finally found the variable.... 🎉

Loaded the RITM page withe developer tools running, then, using the elements tab I searched for changed.

Going through each occurrence (only 18 found) and reviewing what else was wrapped around it, the variable was identified:

example of the html code identifying changed:

<label for="my_variable" class="control-label sc_editor_label ">
    <span id="status.ni.VE4d1234553beb5610c1409047f4e45aa4" aria-label="" title="" mandatory="false" oclass=" required-marker" class="changed required-marker label_description" data-original-title="">&nbsp;</span>
    <span class="sn-tooltip-basic " data-toggle="tooltip" data-placement="auto" role="heading" aria-level="3" aria-label="My Variable">My Variable</span>
    <span id="status.button.ni.VE4d1234553beb5610c1409047f4e45aa4" aria-label="" title="" label-title="" tabindex="0" role="button" class="icon-help btn-default" style="display: none;" aria-hidden="true" data-original-title=""></span>
</label>