What exactly is the use of 'Run script' in a transform map?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2023 03:42 AM
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.
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2023 04:01 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2023 04:10 AM
@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.
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2023 04:18 AM
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2023 04:37 AM
Did you check the explanation link I shared above?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader