How do I get autoSysField(false) to work?

Ricky S Larsson
Tera Guru

How is autoSysField(false) supposed to work?

I'm trying to use it in a background script to retroactively update request record that are closed but still in the active state and I don't want the sys_updated_by and sys_updated_on to be changed. With the following script, sys_updated_by still shows my name and sys_updated_on is the current time

var gr = new GlideRecord('sc_request');
gr.addQuery('active','true');
gr.addQuery('state', 7);
gr.query();
while (gr.next()) {
  gr.setWorkflow(false);
  gr.autoSysField(false);
  gr.setValue ('active', 'false');
  gr.update();
}

What do I need to change in my script to be able to update those records without altering the sys_updates?

1 ACCEPTED SOLUTION

Nirosha Uddandi
Kilo Guru

I guess it should be gr.autoSysFields(false); not gr.autoSysField(false);

 

View solution in original post

3 REPLIES 3

Nirosha Uddandi
Kilo Guru

I guess it should be gr.autoSysFields(false); not gr.autoSysField(false);

 

One little spelling error :'D

and now it works as expected

Thank you so much!

Little things Matter 😄

 

You're Welcome