- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 04:58 AM
Hi,
I am setting value of choice field in transform map with script as below but it is not working it will set value as 2-Medium always .
(function transformRow(source, target, map, log, isUpdate) {
if (source.priority== 'High') {
target.priority == gs.setValue("target.priority",1);//1 is 1 - High
}else if (source.priority== 'Medium') {
target.priority== gs.setValue("target.priority",2);// 2 is 2-Medium
}else if (source.priority== 'Low') {
target.priority== gs.setValue("target.priority",3);//3 is 3-Low
}
// Add your code here
})(source, target, map, log, action === "update");
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 05:17 AM
Hi,
(function transformRow(source, target, map, log, isUpdate) {
var priprityVal=source.getValue('priority');
if(priprityVal=='High')
{
target.priority ='1';
}
else if(priprityVal=='Medium')
{
target.priority ='2';
}
else
{
target.priority='3';
}
})(source, target, map, log, action==="update");
Thanks,
Dhananjay

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 05:08 AM
Try using below.
(function transformRow(source, target, map, log, isUpdate) {
gs.log('Source priority is ',source.priority);//check in logs
if (source.priority== 'High') {
target.priority ='1'; //make sure you pass the dictionary value here for priority
}else if (source.priority== 'Medium') {
target.priority= '2';// make sure you pass the dictionary value here for priority
}else if (source.priority== 'Low') {
target.priority='3';//make sure you pass the dictionary value here for priority
}
// Add your code here
})(source, target, map, log, action === "update");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 05:16 AM
Thanks but it is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 05:12 AM
Hi,
how the value is present in the incoming data i.e. import set table; you can use field map script for this; choice action as ignore
Note: ensure you compare proper values in if condition with the incoming values; also use proper source field
I believe it should be u_priority and not priority
answer = (function transformEntry(source) {
// Add your code here
var targetValue = '';
var sourcePriority = source.u_priority;
if(sourcePriority == 'High')
targetValue = 1;
else if(sourcePriority == 'Medium')
targetValue = 2;
else if(sourcePriority == 'Low')
targetValue = 3;
})(source);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 05:15 AM
I have checked all names and values.Those are priority only