- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2021 10:10 PM
Hi all,
Would like to know how we can detect if there is any field change on the form, when a UI action button is clicked.
I tried to use current.changes(); but this is not supported in UI Action, the same with GlideScriptRecordUtil which is not supported for scoped application.
Regards,
Ram
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2021 12:14 AM
You can use this logic for scoped application
It worked well for me earlier
How to get Changed or Modified Fields in ServiceNow Scoped Apps?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2021 10:23 PM
Can you try this in the client side UI action
Checking for Modified or Changed Fields in Script
var field = g_form.getControl('fieldName');
if(field.changed){
// your logic
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2021 10:27 PM
Hi Ankur,
The UI Action is server side, and also portal facing. So i cant make the client check box checked and hence the g_form.
is there any other approach, purely server side, or its even if we can detect the form changes with in the portal client or server side.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2021 10:41 PM
in that case you can use GlideScriptRecordUtil which is Server Side utility
var gru = GlideScriptRecordUtil.get(current);
var changedFieldNames = gru.getChangedFieldNames();
var changedFieldNamesarray = j2js(changedFieldNames);
var arrayUtil = new ArrayUtil();
gs.info('length ' + changedFieldNamesarray.length);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2021 11:49 PM
Tired the above code in UI Action, but getting below error, looks like its not supported for scoped application.
GlideScriptRecordUtil is not allowed in scoped applications.