Difference Between Run Script, Use Source Script, and Transform Script in Transform Maps

Astik Thombare
Tera Sage

Hello Community,

 

Can someone please explain the difference between Run Script, Source Script, and Transform Script in the context of Transform Maps in ServiceNow? Specifically, I would like to know when to use each type of script and in what scenarios they are appropriate.

 

It would be great if you could provide examples for better understanding.

 

Thank you in advance!

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@Astik Thombare 

Run script - used during the transformation more or less similar to onBefore

source script- used to handle during field map

Transform script - there are different types

check this for better explanation

Validating the order of execution for transform map scripts 

Sequence of transform scripts? 

Transform Event 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

View solution in original post

Runjay Patel
Giga Sage

Hi @Astik Thombare ,

 

See below details.

1. Source Script: It executed before any field mapping occurs, while reading records from the import set.

example: If you want to modify or filter source data before it is mapped to the target table.

 

2. Transform Script: It executed during field mapping, before the data is inserted/updated into the target table.

Example: if you want to do some manupulation on data based on event like onStart, onComplete and so on.

 

3. Run Script: It use to transform field values in the source table to the target table. ServiceNow runs the transform map script in addition to any Field Maps.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Astik Thombare 

Run script - used during the transformation more or less similar to onBefore

source script- used to handle during field map

Transform script - there are different types

check this for better explanation

Validating the order of execution for transform map scripts 

Sequence of transform scripts? 

Transform Event 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

KoteswaraVM
Tera Expert

Hi @Astik Thombare ,

In ServiceNow, Run Script, Source Script, and Transform Script are different types of scripts used in Transform Maps during data import. Here’s the difference between them:

1. Run Script
• Executes after the entire transformation process is complete.
• Typically used for post-processing actions like data validation, triggering business rules, or sending notifications.
• Runs once per import, not for each record.
• Example Use Case: Sending an email after all records have been imported.

2. Source Script
• Runs before the data is processed by the Transform Map.
• Used to manipulate raw source data before it gets mapped to the target table.
• Can be used to clean, format, or restructure incoming data.
• Example Use Case: Splitting a full name field into first and last name before mapping.

Script Example:

source.u_first_name = source.u_full_name.split(' ')[0];
source.u_last_name = source.u_full_name.split(' ')[1];



3. Transform Script
• Executes during the transformation process, for each record being imported.
• Used to manipulate data as it is being mapped to the target table.
• Runs per record, allowing conditional logic and data formatting.
• Example Use Case: Converting status values from an external system to ServiceNow values.

Example:

if (source.u_status == 'Active') {
   target.state = '1';  // '1' could be the equivalent of Active in ServiceNow
} else {
   target.state = '3';  // '3' could mean Inactive
}




I hope this information helps. Please mark my response helpful if it helped.



Thanks,
Koteswara Vara Prasad M

Runjay Patel
Giga Sage

Hi @Astik Thombare ,

 

See below details.

1. Source Script: It executed before any field mapping occurs, while reading records from the import set.

example: If you want to modify or filter source data before it is mapped to the target table.

 

2. Transform Script: It executed during field mapping, before the data is inserted/updated into the target table.

Example: if you want to do some manupulation on data based on event like onStart, onComplete and so on.

 

3. Run Script: It use to transform field values in the source table to the target table. ServiceNow runs the transform map script in addition to any Field Maps.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------