What exactly is the use of 'Run script' in a transform map?

Suggy
Giga Sage

What exactly is the use of 'Run script' in a transform map?  I am not looking for definition, but need some use case scenarios to understand the actual use of it.

Suggy_0-1702294914372.png

 

I have seen few posts like this - https://www.servicenow.com/community/developer-forum/how-to-use-run-script-in-transform-map/m-p/2439... where it says you can do data validations, but you can do that validations in the field mapping part only right?

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Suggy 

that's correct it's similar to onBefore transform script but they have some sequence in which they run.

I have seen some cases where developers don't write transform script but simply use Run script

good explanation here

Difference between Script when checked "Run Script" true and "Transform Scripts" in Transform Map 

check these links

Transform Maps - Order of execution 

Validating the order of execution for transform map scripts 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

SANDEEP28
Mega Sage

@Suggy If "Run script" is selected then you can use script to map source table fields to target table fields. We use this whenever you want to alter/change the source field data then assign it to target fields.

 

Let say we have a "sys_user" as target table and "Imp_user" as source table.  In User(sys_user) target table,  we have field called as "user_name" which is combination of "First Name"  and 'Last Name'. But in the source table(Imp_user). we have two separate fields "First Name" and "Last Name". So in this case, I need to concatenate "First Name" & "Last Name" of source table and then map it to "user_name" field of target table. This we can do by using script only by checking "Run script" checkbox.

 

SANDEEP28_0-1702296490501.png

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

 

@SANDEEP28 That I can manage is transform script or field map script also right? So its a 'Run script'  is a rendundant option for me, unless I am missing something.

@Suggy 

Did you check the explanation link I shared above?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader