Transform Script to update Location field in Transform Map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2022 11:32 PM
Hi ,
I need to update the Target field based on the input from Source in Transform Map .
Below is the Source Fields and Traget field
Need to hard code through script for the following
For Example : if (San Newyork) update in target as Newyork
Please help on this writing transform script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2022 11:52 PM
Hello
you can write source script as follows
if (source.<source field> == "San Newyork")
{
target.<target field> = "Newyork";
}
Hope it helps
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2022 11:55 PM
Hi ,
Need something like elsif ? I attached above with three rows

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 12:17 AM
Then do it like this
if (source.<source field> == "San Newyork")
{
target.<target field> = "Newyork";
}
else if (source.<source field> == "Oracle Melbourne")
{
target.<target field> = "Melbourne";
}
else if (source.<source field> == "WebLogic eCOM America" || source.<source field> == "VmMORREF.....")
{
target.<target field> = "America";
}
Hope it helps..!!
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 12:25 AM
Hi,
Since target field is reference you need to set sys_id OR you can use setDisplayValue() if you know the exact name of location
something like this; adding to what Sulabh shared
if (source.u_source_data_center == "San Newyork")
{
target.setDisplayValue("locationField","Newyork");
}
else if (source.u_source_data_center == "Oracle Melbourne")
{
target.setDisplayValue("locationField","Melbourne");
}
else if (source.u_source_data_center == "WebLogic eCOM America" || source.u_source_data_center == "VmMORREF.....")
{
target.setDisplayValue("locationField","America");
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader