Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Update record in flow without updating system fields

brianlan25
Kilo Patron

I have a requirement to nudge users who's incidents are on hold and not updated in 5 day. So I was thinking I could use a flow to put in work notes ask the assigned to, to provide updates on there incidents. But I don't want them to fall off because my flow added work notes. I know I can use autoSysFields(false) in a GlideRecord script but I was wondering if this can be done in flow without having to make my own action?

5 REPLIES 5

Tanushree Maiti
Tera Patron

Hi @brianlan25 

 

Unfortunately, you cannot suppress sys fields (like sys_update_on) natively in Flow Designer without a custom action.

 

Option1 : You can write your own custom script inside a standard Flow  Script step

Sample code:

 

(function execute(inputs, outputs) {
var gr = new GlideRecord('incident');
if (gr.get(inputs.sys_id)) {
gr.autoSysFields(false); // don't update sys_updated_on / sys_updated_by
gr.setWorkflow(false); // skip BR(optional but common)
gr.setValue('work_notes', inputs.work_notes);
gr.update();
}
})(inputs, outputs);

 

Option2:  using Scheduled Script (skip Flow entirely)

If the nudge logic is straightforward, a Scheduled Job with a script might be simpler end-to-end:

Sample code 
var gr = new GlideRecord('incident');
gr.addQuery('state', 'on_hold');
gr.addQuery('sys_updated_on', '<', gs.daysAgoStart(5));
gr.addQuery('assigned_to', '!=', '');
gr.query();

while (gr.next()) {
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.work_notes = 'This incident has been on hold for 5+ days without an update. Please provide a status update.';
gr.update();
}

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti