The CreatorCon Call for Content is officially open! Get started here.

'Created by 'field on the target table is updating as a 'system' by default. i am unable to change it using field map/transform script

Ranjita Hegde1
Tera Contributor

Hi Everyone,

The 'Created by' field on the target table is updating as a 'system' by default from transform map.

I am unable to modify it to my required user account by using field map script/transform script/run script.

Could anybody please help me to resolve this?

sample code I used:

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

// Add your code here

target.sys_created_by = "abc.xyz";
target.sys_updated_by = "abc.xyz";


})(source, map, log, target);

Thanks & Regards

Ranjita Hegde

1 ACCEPTED SOLUTION

Hi,

You can achieve that by adding one line in your code just before you are trying to set Created BY and Updated by as below:

target.autoSysFields(false);
target.sys_created_by = "abc.xyz";
target.sys_updated_by = "abc.xyz";

However it is not a good practice to override System generated fields. Refer the HI Article from HI on the same topic:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0859763

Go through it nd then take your decision.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

4 REPLIES 4

Saurav11
Kilo Patron
Kilo Patron

Hello,

The created by and Updated by field tasks the name of the user who actually runs the activity. So if you are manually running the transform script it should by default take your name unless you have used the below somewhere

autoSysFields(false); 

 

Please mark answer correct/helpful based on impact.

 

 

Kieran Anson
Kilo Patron

Do you need the value to change per row, or do you just want to set it to something other than system?

One option is to create a scheduled import and set the "run as" field. You can then use the execute now UI Action. This'll run the import as that user, rather than system

Ranjita Hegde1
Tera Contributor

Hi,

Thanks for the Reply.

I am using 'script action' to create the import set. Not using scheduled import. So in this case, cant we use field map script/transform script/run script?

 

Thanks & Regards,

Ranjita Hegde

Hi,

You can achieve that by adding one line in your code just before you are trying to set Created BY and Updated by as below:

target.autoSysFields(false);
target.sys_created_by = "abc.xyz";
target.sys_updated_by = "abc.xyz";

However it is not a good practice to override System generated fields. Refer the HI Article from HI on the same topic:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0859763

Go through it nd then take your decision.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke