<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question how to set value of choice field in transform map? in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359589#M16515</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am&amp;nbsp;setting&amp;nbsp; value of choice field in transform map with script as below but it is not working it will set value as 2-Medium always .&lt;/P&gt;
&lt;P&gt;(function transformRow(source, target, map, log, isUpdate) {&lt;BR /&gt; if (source.priority== 'High') {&lt;BR /&gt; target.priority == gs.setValue("target.priority",1);//1 is 1 - High&lt;BR /&gt; }else if (source.priority== 'Medium') {&lt;BR /&gt; target.priority== gs.setValue("target.priority",2);// 2 is 2-Medium&lt;BR /&gt; }else if (source.priority== 'Low') {&lt;BR /&gt; target.priority== gs.setValue("target.priority",3);//3 is 3-Low&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;// Add your code here&lt;/P&gt;
&lt;P&gt;})(source, target, map, log, action === "update");&lt;/P&gt;</description>
    <pubDate>Thu, 23 Apr 2020 11:58:28 GMT</pubDate>
    <dc:creator>Ashwini Jadhao</dc:creator>
    <dc:date>2020-04-23T11:58:28Z</dc:date>
    <item>
      <title>how to set value of choice field in transform map?</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359589#M16515</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am&amp;nbsp;setting&amp;nbsp; value of choice field in transform map with script as below but it is not working it will set value as 2-Medium always .&lt;/P&gt;
&lt;P&gt;(function transformRow(source, target, map, log, isUpdate) {&lt;BR /&gt; if (source.priority== 'High') {&lt;BR /&gt; target.priority == gs.setValue("target.priority",1);//1 is 1 - High&lt;BR /&gt; }else if (source.priority== 'Medium') {&lt;BR /&gt; target.priority== gs.setValue("target.priority",2);// 2 is 2-Medium&lt;BR /&gt; }else if (source.priority== 'Low') {&lt;BR /&gt; target.priority== gs.setValue("target.priority",3);//3 is 3-Low&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;// Add your code here&lt;/P&gt;
&lt;P&gt;})(source, target, map, log, action === "update");&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 11:58:28 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359589#M16515</guid>
      <dc:creator>Ashwini Jadhao</dc:creator>
      <dc:date>2020-04-23T11:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to set value of choice field in transform map?</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359590#M16516</link>
      <description>&lt;P&gt;Try using below.&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;(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");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 12:08:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359590#M16516</guid>
      <dc:creator>Jaspal Singh</dc:creator>
      <dc:date>2020-04-23T12:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to set value of choice field in transform map?</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359591#M16517</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;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&lt;/P&gt;
&lt;P&gt;Note: ensure you compare proper values in if condition with the incoming values; also use proper source field&lt;/P&gt;
&lt;P&gt;I believe it should be u_priority and not priority&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;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);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Mark &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Correct if this solves your issue and also mark &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; Helpful if you find my response worthy based on the impact.&lt;BR /&gt;Thanks&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 12:12:23 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359591#M16517</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-04-23T12:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to set value of choice field in transform map?</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359592#M16518</link>
      <description>&lt;P&gt;I have checked all names and values.Those are priority only&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 12:15:13 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359592#M16518</guid>
      <dc:creator>Ashwini Jadhao</dc:creator>
      <dc:date>2020-04-23T12:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to set value of choice field in transform map?</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359593#M16519</link>
      <description>&lt;P&gt;Thanks but it is not working&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 12:16:23 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359593#M16519</guid>
      <dc:creator>Ashwini Jadhao</dc:creator>
      <dc:date>2020-04-23T12:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to set value of choice field in transform map?</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359594#M16520</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(function transformRow(source, target, map, log, isUpdate) {&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; var priprityVal=source.getValue('priority');&lt;BR /&gt; if(priprityVal=='High')&lt;BR /&gt; {&lt;BR /&gt; target.priority&amp;nbsp;='1';&lt;BR /&gt; }&lt;BR /&gt; else if(priprityVal=='Medium')&lt;BR /&gt; {&lt;BR /&gt; target.priority&amp;nbsp;='2';&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt;target.priority='3';&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;})(source, target, map, log, action==="update");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Dhananjay&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 12:17:05 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359594#M16520</guid>
      <dc:creator>Dhananjay Pawar</dc:creator>
      <dc:date>2020-04-23T12:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to set value of choice field in transform map?</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359595#M16521</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I believe the answer you marked as correct the same script was already provided by Jaspal and his comment was the 1st response to your question. Any specific reason you didn't mark Jaspal's answer as correct?&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 12:37:37 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-set-value-of-choice-field-in-transform-map/m-p/1359595#M16521</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-04-23T12:37:37Z</dc:date>
    </item>
  </channel>
</rss>

