<?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 Re: Workflow run script activity return undefined for a Reference variable in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/workflow-run-script-activity-return-undefined-for-a-reference/m-p/1507583#M164509</link>
    <description>&lt;P&gt;Looks like you are trying to dot walk to the request_for field.&lt;/P&gt;
&lt;P&gt;If you were referencing the sys_user table for example, you could do &lt;STRONG&gt;current.variables.student_info.email&lt;/STRONG&gt; and that would give you the email address off of the user record for that user.&lt;/P&gt;
&lt;P&gt;If you are just trying to get the request_for field on the Student Info catalog item then it's just &lt;STRONG&gt;current.variables.request_for&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;One thing to keep in mind too is a reference field is going to return the sys_id.&amp;nbsp; You can use .getDisplayValue() to get the actual text instead of the sys_id.&amp;nbsp; Or you can dot walk like I mentioned above to get to any of the fields on the referenced record.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jul 2019 18:26:12 GMT</pubDate>
    <dc:creator>Steven Parker</dc:creator>
    <dc:date>2019-07-10T18:26:12Z</dc:date>
    <item>
      <title>Workflow run script activity return undefined for a Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/workflow-run-script-activity-return-undefined-for-a-reference/m-p/1507580#M164506</link>
      <description>&lt;P&gt;Howdy,&lt;/P&gt;
&lt;P&gt;I am getting "undefined" result when I run script on workflow.&amp;nbsp;It worked for different Variable types but not if I'm using a "Reference" variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variable set type is "Reference"&lt;/P&gt;
&lt;P&gt;Code "current.variables.student_info.request_for"&lt;/P&gt;
&lt;P&gt;Please help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;BR /&gt;Rochellee&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 13:36:40 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/workflow-run-script-activity-return-undefined-for-a-reference/m-p/1507580#M164506</guid>
      <dc:creator>rochelleefernan</dc:creator>
      <dc:date>2019-07-10T13:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Workflow run script activity return undefined for a Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/workflow-run-script-activity-return-undefined-for-a-reference/m-p/1507581#M164507</link>
      <description>&lt;P&gt;what's exactly your variable name ?&lt;/P&gt;
&lt;P&gt;current.variables.&lt;STRONG&gt;student_info.request_for&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;current.variables.&lt;STRONG&gt;student_info&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;current.variables.&lt;STRONG&gt;request_for&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 17:33:54 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/workflow-run-script-activity-return-undefined-for-a-reference/m-p/1507581#M164507</guid>
      <dc:creator>Mike Patel</dc:creator>
      <dc:date>2019-07-10T17:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Workflow run script activity return undefined for a Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/workflow-run-script-activity-return-undefined-for-a-reference/m-p/1507582#M164508</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;If your reference type variable name is student_info, then&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;current.variables.student_info&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is correct, but verify that when you're doing a furthermore dot-walk, then make sure that the table to which you're referencing in student_info variable does have a field named request_for or not? If not, then there is the issue, and that's the reason you're getting undefined return value for this expression. Please verify and correct it.&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;BR /&gt;Mark helpful or correct based on impact.&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 17:45:10 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/workflow-run-script-activity-return-undefined-for-a-reference/m-p/1507582#M164508</guid>
      <dc:creator>Narendra Kota</dc:creator>
      <dc:date>2019-07-10T17:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Workflow run script activity return undefined for a Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/workflow-run-script-activity-return-undefined-for-a-reference/m-p/1507583#M164509</link>
      <description>&lt;P&gt;Looks like you are trying to dot walk to the request_for field.&lt;/P&gt;
&lt;P&gt;If you were referencing the sys_user table for example, you could do &lt;STRONG&gt;current.variables.student_info.email&lt;/STRONG&gt; and that would give you the email address off of the user record for that user.&lt;/P&gt;
&lt;P&gt;If you are just trying to get the request_for field on the Student Info catalog item then it's just &lt;STRONG&gt;current.variables.request_for&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;One thing to keep in mind too is a reference field is going to return the sys_id.&amp;nbsp; You can use .getDisplayValue() to get the actual text instead of the sys_id.&amp;nbsp; Or you can dot walk like I mentioned above to get to any of the fields on the referenced record.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 18:26:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/workflow-run-script-activity-return-undefined-for-a-reference/m-p/1507583#M164509</guid>
      <dc:creator>Steven Parker</dc:creator>
      <dc:date>2019-07-10T18:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: Workflow run script activity return undefined for a Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/workflow-run-script-activity-return-undefined-for-a-reference/m-p/1507584#M164510</link>
      <description>&lt;P&gt;Thanks that did it. So in the script itself I added .getDisplayValue&lt;/P&gt;
&lt;P&gt;From this : current.variables.student_info.request_for&lt;/P&gt;
&lt;P&gt;To This : current.variables.student_info.request_for.getDisplayValue()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks everyone.&lt;/P&gt;
&lt;P&gt;Rochellee&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 06:14:52 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/workflow-run-script-activity-return-undefined-for-a-reference/m-p/1507584#M164510</guid>
      <dc:creator>rochelleefernan</dc:creator>
      <dc:date>2019-07-11T06:14:52Z</dc:date>
    </item>
  </channel>
</rss>

