<?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: Set Display Value Not Working in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103426#M760352</link>
    <description>&lt;P&gt;it seems reference fields are not populating in your target table.&lt;/P&gt;
&lt;P&gt;Please make sure that you are inserting sys_id for reference field data in your inbound action code.&lt;/P&gt;
&lt;P&gt;Please modify your code like below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ar email_string = email.body_text.toString();&lt;BR /&gt;var names = email.body.new_hire_name.toString().split(' ');&lt;BR /&gt;var username = email.body.new_hire_name;&lt;BR /&gt;var manager = email.body.reporting_manager;&lt;BR /&gt;var location = email.body.location;&lt;BR /&gt;var job_title = email.body.position;&lt;BR /&gt;var department = email.body.department;&lt;BR /&gt;var needs_laptop = email.body.needs_laptop;&lt;BR /&gt;var start_date = email.body.orientation_date;&lt;BR /&gt;var email_sys_id = sys_email.sys_id;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;var loc = new GlideRecord('cmn_location');&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;loc.addQuery('name',location);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;loc.query();&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;while(loc.next()){&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;var lc = loc.sys_id;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;current.initialize();&lt;BR /&gt;current.u_new_hire_manager = manager;&lt;BR /&gt;if (names.length == 2)&lt;BR /&gt; {&lt;BR /&gt; current.u_first_name = names[0];&lt;BR /&gt; current.u_last_name = names[1];&lt;BR /&gt; }&lt;BR /&gt;if (names.length == 3)&lt;BR /&gt; {&lt;BR /&gt; current.u_first_name = names[0];&lt;BR /&gt; current.u_last_name = names[2];&lt;BR /&gt; }&lt;BR /&gt;current.u_username = username;&lt;BR /&gt;//current.u_location.setDisplayValue(email.body.location);// sys_id of location&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;current.u_location = lc;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;current.u_job_title.setDisplayValue(email.body.position); // sys_id of job tilte&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;current.u_department.setDisplayValue(email.body.department); // sys_id of department&lt;/STRONG&gt;&lt;BR /&gt;if (needs_laptop == 'Yes')&lt;BR /&gt; {&lt;BR /&gt; current.u_needs_laptop = true;&lt;BR /&gt; }&lt;BR /&gt;if (needs_laptop == 'No')&lt;BR /&gt; {&lt;BR /&gt; current.u_needs_laptop = false;&lt;BR /&gt; }&lt;BR /&gt;current.u_start_date = start_date;&lt;BR /&gt;current.description = email_string;&lt;BR /&gt;current.state = 1;&lt;BR /&gt;current.assignment_group = '3adacb8813ad6e00d9ff30ded144b011';&lt;BR /&gt;current.short_description = 'New Hire Onboarding - ' + username;&lt;BR /&gt;current.reference_email = email_sys_id;&lt;BR /&gt;current.insert();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Sachin&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jul 2018 17:26:44 GMT</pubDate>
    <dc:creator>sachin_namjoshi</dc:creator>
    <dc:date>2018-07-31T17:26:44Z</dc:date>
    <item>
      <title>Set Display Value Not Working</title>
      <link>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103420#M760346</link>
      <description>&lt;P&gt;Hello Community!&lt;/P&gt;
&lt;P&gt;I am running an inbound email action to parse out an email. I am then using the set display value method on variables on my form that it creates. Some variables are filling in and working and some are not. I am hoping you can help me figure out why. Below is a copy of my inbound email action, and some form info. One weird thing that is happening is that it will set the job title to a value like a string, but you can't see it on the form and it's not referencing that table.&lt;/P&gt;
&lt;P&gt;INBOUND EMAIL&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;Hello IT Service Desk,&lt;/P&gt;
&lt;P&gt;This is a request for IT to setup for the new hire.&lt;/P&gt;
&lt;P&gt;New Hire Name: Emily M Vranes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;New Hire/Rehire:&amp;nbsp;Yes - New Hire&lt;/P&gt;
&lt;P&gt;Position:&amp;nbsp;Customer Support Rep Level I&lt;/P&gt;
&lt;P&gt;Department:&amp;nbsp;Client Support - UT&lt;/P&gt;
&lt;P&gt;Location:&amp;nbsp;Draper Headquarters&lt;/P&gt;
&lt;P&gt;Needs Laptop:&amp;nbsp;No&lt;/P&gt;
&lt;P&gt;Orientation Date:&amp;nbsp;2018-08-06&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Start Date: Monday, August 06, 2018&lt;BR /&gt;Reporting Manager: Eva Ariceaga&lt;BR /&gt;Manager's email: ***.****@****leasing.com&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;HR Department&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INBOUND EMAIL ACTION&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var email_string = email.body_text.toString();
var names = email.body.new_hire_name.toString().split(' ');
var username = email.body.new_hire_name;
var manager = email.body.reporting_manager;
var location = email.body.location;
var job_title = email.body.position;
var department = email.body.department;
var needs_laptop = email.body.needs_laptop;
var start_date = email.body.orientation_date;
var email_sys_id = sys_email.sys_id;

current.initialize();
current.u_new_hire_manager = manager;
if (names.length == 2)
	{
		current.u_first_name = names[0];
		current.u_last_name = names[1];
	}
if (names.length == 3)
	{
		current.u_first_name = names[0];
		current.u_last_name = names[2];
	}
current.u_username = username;
current.u_location.setDisplayValue(email.body.location);
current.u_job_title.setDisplayValue(email.body.position);
current.u_department.setDisplayValue(email.body.department);
if (needs_laptop == 'Yes')
	{
		current.u_needs_laptop = true;
	}
if (needs_laptop == 'No')
	{
		current.u_needs_laptop = false;
	}
current.u_start_date = start_date;
current.description = email_string;
current.state = 1;
current.assignment_group = '3adacb8813ad6e00d9ff30ded144b011';
current.short_description = 'New Hire Onboarding - ' + username;
current.reference_email = email_sys_id;
current.insert();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;THE CREATED RECORD FROM THE INBOUND ACTION&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/64467i8DFC03267614066D/image-size/large?v=v2&amp;amp;px=999" srcset="/community/image/serverpage/image-id/64467i8DFC03267614066D/image-size/large?v=v2&amp;amp;px=999 1.0x" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I filled in Location, Start Date, Job Title, and Department. Those are the fields that are not auto filling, every other field is auto filling from my inbound action. Any tips or help or questions would be great, thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 16:19:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103420#M760346</guid>
      <dc:creator>kazidon</dc:creator>
      <dc:date>2018-07-31T16:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Set Display Value Not Working</title>
      <link>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103421#M760347</link>
      <description>&lt;P&gt;Can you add some logs? When you use display value, it should match the exact text in the reference table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var email_string = email.body_text.toString();
var names = email.body.new_hire_name.toString().split(' ');
var username = email.body.new_hire_name;
var manager = email.body.reporting_manager;
var location = email.body.location;
var job_title = email.body.position;
var department = email.body.department;
var needs_laptop = email.body.needs_laptop;
var start_date = email.body.orientation_date;
var email_sys_id = sys_email.sys_id;

current.initialize();
current.u_new_hire_manager = manager;
if (names.length == 2)
	{
		current.u_first_name = names[0];
		current.u_last_name = names[1];
	}
if (names.length == 3)
	{
		current.u_first_name = names[0];
		current.u_last_name = names[2];
	}
current.u_username = username;
gs.info('+++++++++email.body.location is '+email.body.location);
gs.info('+++++++++email.body.position is '+email.body.position);
gs.info('+++++++++email.body.department is '+email.body.department);
current.u_location.setDisplayValue(email.body.location);
current.u_job_title.setDisplayValue(email.body.position);
current.u_department.setDisplayValue(email.body.department);
if (needs_laptop == 'Yes')
	{
		current.u_needs_laptop = true;
	}
if (needs_laptop == 'No')
	{
		current.u_needs_laptop = false;
	}
current.u_start_date = start_date;
current.description = email_string;
current.state = 1;
current.assignment_group = '3adacb8813ad6e00d9ff30ded144b011';
current.short_description = 'New Hire Onboarding - ' + username;
current.reference_email = email_sys_id;
current.insert();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jul 2018 16:26:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103421#M760347</guid>
      <dc:creator>SanjivMeher</dc:creator>
      <dc:date>2018-07-31T16:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Set Display Value Not Working</title>
      <link>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103422#M760348</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please check if these values exists in referencing table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 16:41:42 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103422#M760348</guid>
      <dc:creator>Upender Kumar</dc:creator>
      <dc:date>2018-07-31T16:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Set Display Value Not Working</title>
      <link>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103423#M760349</link>
      <description>&lt;P&gt;thanks for the reply! yeah, they all are in the table. We just cloned our production instance back to our RC instance and I was able to test an onboarding email like above in RC and everything worked fine. We just cloned back over the weekend.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 17:06:04 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103423#M760349</guid>
      <dc:creator>kazidon</dc:creator>
      <dc:date>2018-07-31T17:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Set Display Value Not Working</title>
      <link>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103424#M760350</link>
      <description>&lt;P&gt;Thanks for the reply, how can I add some logs to that and where do I get those logs to post here? yeah, they all are in the table. We just cloned our production instance back to our RC instance and I was able to test an onboarding email like above in RC and everything worked fine. We just cloned back over the weekend.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 17:06:57 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103424#M760350</guid>
      <dc:creator>kazidon</dc:creator>
      <dc:date>2018-07-31T17:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Set Display Value Not Working</title>
      <link>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103425#M760351</link>
      <description>&lt;P&gt;The script I posted, I added the logs to it. You just need to use that script. After sending an inbound email, check the system logs and you should see those logs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;gs.info('+++++++++email.body.location is '+email.body.location);
gs.info('+++++++++email.body.position is '+email.body.position);
gs.info('+++++++++email.body.department is '+email.body.department);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jul 2018 17:08:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103425#M760351</guid>
      <dc:creator>SanjivMeher</dc:creator>
      <dc:date>2018-07-31T17:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Set Display Value Not Working</title>
      <link>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103426#M760352</link>
      <description>&lt;P&gt;it seems reference fields are not populating in your target table.&lt;/P&gt;
&lt;P&gt;Please make sure that you are inserting sys_id for reference field data in your inbound action code.&lt;/P&gt;
&lt;P&gt;Please modify your code like below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ar email_string = email.body_text.toString();&lt;BR /&gt;var names = email.body.new_hire_name.toString().split(' ');&lt;BR /&gt;var username = email.body.new_hire_name;&lt;BR /&gt;var manager = email.body.reporting_manager;&lt;BR /&gt;var location = email.body.location;&lt;BR /&gt;var job_title = email.body.position;&lt;BR /&gt;var department = email.body.department;&lt;BR /&gt;var needs_laptop = email.body.needs_laptop;&lt;BR /&gt;var start_date = email.body.orientation_date;&lt;BR /&gt;var email_sys_id = sys_email.sys_id;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;var loc = new GlideRecord('cmn_location');&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;loc.addQuery('name',location);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;loc.query();&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;while(loc.next()){&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;var lc = loc.sys_id;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;current.initialize();&lt;BR /&gt;current.u_new_hire_manager = manager;&lt;BR /&gt;if (names.length == 2)&lt;BR /&gt; {&lt;BR /&gt; current.u_first_name = names[0];&lt;BR /&gt; current.u_last_name = names[1];&lt;BR /&gt; }&lt;BR /&gt;if (names.length == 3)&lt;BR /&gt; {&lt;BR /&gt; current.u_first_name = names[0];&lt;BR /&gt; current.u_last_name = names[2];&lt;BR /&gt; }&lt;BR /&gt;current.u_username = username;&lt;BR /&gt;//current.u_location.setDisplayValue(email.body.location);// sys_id of location&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;current.u_location = lc;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;current.u_job_title.setDisplayValue(email.body.position); // sys_id of job tilte&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;current.u_department.setDisplayValue(email.body.department); // sys_id of department&lt;/STRONG&gt;&lt;BR /&gt;if (needs_laptop == 'Yes')&lt;BR /&gt; {&lt;BR /&gt; current.u_needs_laptop = true;&lt;BR /&gt; }&lt;BR /&gt;if (needs_laptop == 'No')&lt;BR /&gt; {&lt;BR /&gt; current.u_needs_laptop = false;&lt;BR /&gt; }&lt;BR /&gt;current.u_start_date = start_date;&lt;BR /&gt;current.description = email_string;&lt;BR /&gt;current.state = 1;&lt;BR /&gt;current.assignment_group = '3adacb8813ad6e00d9ff30ded144b011';&lt;BR /&gt;current.short_description = 'New Hire Onboarding - ' + username;&lt;BR /&gt;current.reference_email = email_sys_id;&lt;BR /&gt;current.insert();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Sachin&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 17:26:44 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103426#M760352</guid>
      <dc:creator>sachin_namjoshi</dc:creator>
      <dc:date>2018-07-31T17:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Set Display Value Not Working</title>
      <link>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103427#M760353</link>
      <description>&lt;P&gt;the freaking email that we were getting sent had " " spaces in front (face palm) just added .trim() to my variables that were not mapping over, and that fixed it!&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 19:24:59 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103427#M760353</guid>
      <dc:creator>kazidon</dc:creator>
      <dc:date>2018-07-31T19:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: Set Display Value Not Working</title>
      <link>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103428#M760354</link>
      <description>&lt;P&gt;thanks for you help on this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the freaking email that we were getting sent had " " spaces in front (face palm) just added .trim() to my variables that were not mapping over, and that fixed it!&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 19:25:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/set-display-value-not-working/m-p/2103428#M760354</guid>
      <dc:creator>kazidon</dc:creator>
      <dc:date>2018-07-31T19:25:24Z</dc:date>
    </item>
  </channel>
</rss>

