How to restricted the system updated fields when any record get updated.

vinuth v
Tera Expert

Hi All,

 

I want to update the few records in the table but it should not update the system fields like updated.

 

Please any one suggest me how to do this one,

 

Thanks,

Vinuth

6 REPLIES 6

abirakundu23
Mega Sage

Hi @vinuth v ,

Please use API autoSysField(false);

To get more details please follow below links:
Can we update system fields like 'Updated by' and 'Created by' from some old value to a new value th...
GlideRecord Query Cheat Sheet – ServiceNow Guru

Please mark helpful & accept answer if its worthy for you.



swathisarang98
Giga Sage
Giga Sage

Hi @vinuth v ,

 

You can try something as below,

 

try {
    var gr = new GlideRecord('incident');
    gr.addEncodedQuery('state=1'); // queries for state new
	gr.setWorkflow(false); // stops the running of any business rule or sending out any notification
	gr.autoSysFields(false); //stops the updation of fields like created by or updated by
    gr.query();
    while (gr.next()) {
        gr.description = "Testing";
		gr.update();
    }
} catch (e) {
    gs.print('error' + e);
}

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang