Need to update the createdby & updated by

Vinay49
Tera Expert

Hello All,

 

Thorough the script I want to update the created by & updated by forcefully. 
I was trying like below
gr.sysAutofield(false);

gr.sys_created_by = 'Test';

gr.updated_by = 'Test';

However, created on & updated on & updated or not getting updated & showing empty.

My requirement is to update only createdby & updated by with "Test". It should not impact on created on &  updated on.

is it possible? if yes, can you help me with the code.

 

Thanks in advance

7 REPLIES 7

Community Alums
Not applicable

 

gr.sys_created_by = 'Test';

gr.sys_updated_by = 'Test';

// I dont think you need this - > gr.autoSysFields(false); //Do not update gr.autoSysFields(false); //Do not update system fields
gr.setForceUpdate(true); //Force the update
gr.setUseEngines(false);
gr.update();

Ankit Kumar6
Tera Contributor

Hello Vinay,

Try with below code:

gr.autoSysFields(false);
gr.sys_created_by='Test';
gr.sys_updated_by='Test'
gr.update();
 
Thanks,
Ankit
 
Please mark this response as correct and helpful if it helps you.

Amit Gujarathi
Giga Sage
Giga Sage

HI @Vinay49 ,
I trust you are doing great.

 

Here's the sample code:

 

var gr = new GlideRecord('your_table_name'); // Replace 'your_table_name' with the actual table name
gr.addQuery('your_query_field', 'your_query_value'); // Replace with your query parameters
gr.query();

if (gr.next()) {
    gr.autoSysFields(false); // Disables auto-updating of system fields
    gr.sys_created_by = 'Test';
    gr.updated_by = 'Test';
    gr.update(); // Saves the record with the new values
}
 

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi