<?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: Populate a reference variable on a catalog item - catalog client script in ITOM forum</title>
    <link>https://www.servicenow.com/community/itom-forum/populate-a-reference-variable-on-a-catalog-item-catalog-client/m-p/909535#M15902</link>
    <description>&lt;P&gt;Found the solution, just took a lot of testing and . Thanks for y'alls help!&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;In case someone else runs into this problem here was the solution:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;function onChange(control, oldValue, newValue, isLoading) { &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (newValue == '') {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setValue('visitor_access_which_post', '');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!g_form.getControl('visitor_access_which_post'))&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; var caller = g_form.getReference('customer_info_requestor', setLocation);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;function setLocation(caller) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (caller)&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setValue('visitor_access_which_post', caller.location);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 14 Jul 2014 20:17:10 GMT</pubDate>
    <dc:creator>Nate23</dc:creator>
    <dc:date>2014-07-14T20:17:10Z</dc:date>
    <item>
      <title>Populate a reference variable on a catalog item - catalog client script</title>
      <link>https://www.servicenow.com/community/itom-forum/populate-a-reference-variable-on-a-catalog-item-catalog-client/m-p/909532#M15899</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P style="min-height: 8pt; height: 8pt; padding: 0px;"&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried a number of things, but can't seem to populate this reference field. Here is the scenario:&lt;/P&gt;&lt;P style="min-height: 8pt; height: 8pt; padding: 0px;"&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;This Catalog Item has a reference variable to pull current user from the sys_user table. I have another reference field on the catalog item to the cmn_location. This is also a reference field in the sys_user table. The client wants their location to auto populate. I tried dot walking, and querying, but can't seem to get the reference field to populate. when I try to display this is an alert I get [Object] [Object].&lt;/P&gt;&lt;P style="min-height: 8pt; height: 8pt; padding: 0px;"&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;I've went through my stages of different code, but for visual purposes here is the onLoad client script: &lt;/P&gt;&lt;P style="min-height: 8pt; height: 8pt; padding: 0px;"&gt; &amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style=";"&gt;&lt;/TD&gt;&lt;TD style=";"&gt;var gr = new GlideRecord('sys_user'); &amp;nbsp; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style=";"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/TD&gt;&lt;TD style=";"&gt;gr.addQuery('user_name', g_form.getValue('customer_info_requestor')); &amp;nbsp; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style=";"&gt;&lt;/TD&gt;&lt;TD style=";"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style=";"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/TD&gt;&lt;TD style=";"&gt;gr.query(); &amp;nbsp; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(gr.next()){&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style=";"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/TD&gt;&lt;TD style=";"&gt;g_form.setValue('visitor_access_which_post', gr.location); &amp;nbsp; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P style="min-height: 8pt; height: 8pt; padding: 0px;"&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;Any Ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jul 2014 19:29:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/populate-a-reference-variable-on-a-catalog-item-catalog-client/m-p/909532#M15899</guid>
      <dc:creator>Nate23</dc:creator>
      <dc:date>2014-07-14T19:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Populate a reference variable on a catalog item - catalog client script</title>
      <link>https://www.servicenow.com/community/itom-forum/populate-a-reference-variable-on-a-catalog-item-catalog-client/m-p/909533#M15900</link>
      <description>&lt;P&gt;Hi Nathan,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Could you try using "variables" prior to variable name? Check if that does any difference in the outcome&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Mandar&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jul 2014 19:38:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/populate-a-reference-variable-on-a-catalog-item-catalog-client/m-p/909533#M15900</guid>
      <dc:creator>ohhgr</dc:creator>
      <dc:date>2014-07-14T19:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Populate a reference variable on a catalog item - catalog client script</title>
      <link>https://www.servicenow.com/community/itom-forum/populate-a-reference-variable-on-a-catalog-item-catalog-client/m-p/909534#M15901</link>
      <description>&lt;P&gt;Hey Mandar,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;This is a catalog client script, not a client script, so if you mean using variables.variable_Name this does not work either. It's driving me crazy.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Nathan&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jul 2014 19:44:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/populate-a-reference-variable-on-a-catalog-item-catalog-client/m-p/909534#M15901</guid>
      <dc:creator>Nate23</dc:creator>
      <dc:date>2014-07-14T19:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Populate a reference variable on a catalog item - catalog client script</title>
      <link>https://www.servicenow.com/community/itom-forum/populate-a-reference-variable-on-a-catalog-item-catalog-client/m-p/909535#M15902</link>
      <description>&lt;P&gt;Found the solution, just took a lot of testing and . Thanks for y'alls help!&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;In case someone else runs into this problem here was the solution:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;function onChange(control, oldValue, newValue, isLoading) { &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (newValue == '') {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setValue('visitor_access_which_post', '');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!g_form.getControl('visitor_access_which_post'))&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; var caller = g_form.getReference('customer_info_requestor', setLocation);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;function setLocation(caller) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (caller)&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setValue('visitor_access_which_post', caller.location);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jul 2014 20:17:10 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itom-forum/populate-a-reference-variable-on-a-catalog-item-catalog-client/m-p/909535#M15902</guid>
      <dc:creator>Nate23</dc:creator>
      <dc:date>2014-07-14T20:17:10Z</dc:date>
    </item>
  </channel>
</rss>

