
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 10:11 AM
Hi guys, is it possible to check if one of the fields was updated in Script Include ? im populate fields with script include rest api data, and i need to check if fields the same - do not update it
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2020 08:19 AM
Hi,
Since you have multiple record sys_ids you need to iterate over each record and check
Also if you want to check for multiple fields then you need to check them one by one and if not same then update
sample script below:
as.addQuery('id', 'IN', ids);
as.query();
while(as.next()){
for(var i=0;i<result.length;i++){
if(as.u_account_status != result[i].AccountStatus)
as.u_account_status = result[i].AccountStatus;
if(as.u_account_status_name != result[i].AccountStatusName)
as.u_account_status_name = result[i].AccountStatusName;
as.update();
}
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
06-21-2020 10:55 AM
Yes, but if using in if(as.next) it will found matching in founded record ? Or I’m wrong ? I will check later and give you an answer, if you are interested

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 10:15 AM
Hi Serhii,
Does this mean fields on the Script include or fields from the script in Script include.
If fields on Script include you can add a Related List named Version to the form & give a check or You can check the History for the Script include by Right clicking the Form Header & then History.
If fields from script of Script include than you need to look for the table that is being GlideRecorded & then check the same as above.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 10:56 AM
Hi,
Are you using any webservice or directly updating the records from the response received in script include? if you are using Webservice (staging table and transform map) then it automatically takes care of when to change record. if no new update then it skips it.
If you are directly updating record then you will need to compare every single field value with the new value and if the value is different than update otherwise simply ignore the iteration.
Let me know if any further details are required.
Thanks & Regards,
Sharjeel
Muhammad