Transform Map Script to Convert Currency
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2018 11:37 AM
I am currently working on creating a transform map that will process advanced shipping notices for software licenses being purchased. The vendor emails a spreadsheet with the information in the local currency based on where it was purchased. The cost information is contained in 2 separate columns on the spreadsheet (unit price and currency). I want to write a script that would convert the unit price to USD and load that data into the cost field on the license asset record. I know that ServiceNow loads exchange rates that may be used to perform the conversion. I'm not sure how to write the script. If the currency is in USD, the calculation can be bypassed and the unit price mapped to cost as is.
I would appreciate assistance in getting this accomplished.
Thank you.
- Labels:
-
Enterprise Asset Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2018 10:29 AM
Hello Sharon,
1) Write a script here in the transform map
Note: Please check the run script check box and write a script
Alternative way:- This could be achieved using writing onbefore script as well
2) -----script-------
// I want to write a script that would convert the unit price to USD and load that data into the cost field on the license asset record.
if (!source.unit_price.nil() && source.unit_price != 'Dollars'){//if unit price shouldn't be empty and not dollars
target.cost_field = 'Dollars';
}else{//if it dollars then allow the source field to map to target fied
target.cost_field = source.unit_price;
}
Please mark the answer as correct and helpful if it helped you,...!!
Regards,
Chalan
https://www.linkedin.com/messaging/thread/6463808521644363776/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2018 10:43 AM
Thank you Chalan for the reply. I need the script to also do the calculation for converting the price to US Dollars. ServiceNow does have exchange rates loading daily so I was thinking that the script could use the exchange rates from within ServiceNow to calculate the USD equivalent. Unless I'm missing something in the above script, I don't see where it's converting the price to US Dollars.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2018 10:57 AM
https://docs.servicenow.com/bundle/london-platform-administration/page/administer/currency/concept/currency-conversions.html
Going through the above docs would help you.
What you could do is anyways this transform map will be automated so after loaded just run the above mentioned schedule job as mentioned in doc above.
Please mark the answer as correct and helpful if it helped you..!!!
Regards,
Chalan
https://www.linkedin.com/in/chalan-b-l-4a438273/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2018 11:16 AM
Hello Sharon,
After you implement the solution try to post the answer in this thread so that it will help others in the community.
If you got enough information please do mark the above solution as correct.
Regards,
Chalan
https://www.linkedin.com/in/chalan-b-l-4a438273/