- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 09:46 PM - edited 03-17-2023 01:43 AM
I created one fix script(global scope) to update resolve time(field type - integer) field in the Universal request.
The update function is not working and it's happening only for the Universal request same functionality is used for the general request and it's working fine there.
Fix script code -
resolvetime();
function resolvetime()
{
var sw = new GlideRecord('universal_request');
sw.addQuery('sys_id', ' sys_id of the universal request '); // passing sys_id of specific record to check
sw.query();
if (sw.next()) {
var opened = sw.opened_at.getDisplayValue(); // UR open time
var resolve = sw.u_resolved.getDisplayValue(); // UR resolve time
var date = gs.dateDiff(opened, resolve, true); // diff is in the seconds
gs.info("@#$ datediff " + date);
sw.u_resolved_time = date;
gs.info("@#$ resolve time value "+ sw.u_resolved_time);
sw.update(); // this function is not working
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 05:02 AM
When you run this Fix Script, obviously it seems like you are not seeing the records updated, but does it show the correct info logs? Is there any indication on the progress worker for the fix script or the runtime window in foreground that the update did not execute correctly? Is there anything in the system logs at this same time that gives any insight? Are you able to update the same field on this record manually by viewing the record? There may be a data policy, ACL, or Business Rule preventing the update. To that end, try adding a line before the update to prevent any business rules from running before/after the record is updated:
sw.setWorkflow(false);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 05:02 AM
When you run this Fix Script, obviously it seems like you are not seeing the records updated, but does it show the correct info logs? Is there any indication on the progress worker for the fix script or the runtime window in foreground that the update did not execute correctly? Is there anything in the system logs at this same time that gives any insight? Are you able to update the same field on this record manually by viewing the record? There may be a data policy, ACL, or Business Rule preventing the update. To that end, try adding a line before the update to prevent any business rules from running before/after the record is updated:
sw.setWorkflow(false);