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?

1 ACCEPTED SOLUTION

Aditya_hublikar
Giga Sage

Hello @brianlan25 ,

As per my understanding, it is not possible to update Work Notes using Flow Designer without affecting the system fields, since the standard Update Record action does not provide an option equivalent to autoSysFields(false).

If you are okay with using autoSysFields(false), you can use it in a Script step. Otherwise, if the requirement is simply to notify the Assigned To about an Incident that has been on hold for 5 days, you can send a notification to the Assigned To instead of updating the Work Notes.

 

If this helps you then m ark it as helpful and accept as solution.

Regards,
Aditya

View solution in original post

6 REPLIES 6

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

brianlan25
Kilo Patron

I have decided to use a scheduled job along with a mail script that will send 1 notification with a list of task that need to be updated. Instead of one notification per task.