<?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 Auto Populate email id of user in email field whose name is specified in Requested For field of a Request form. in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/how-to-auto-populate-email-id-of-user-in-email-field-whose-name/m-p/250777#M1971</link>
    <description>&lt;P&gt;How to Auto Populate email id of user in email field whose name is specified in Requested For field of a Request form.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jul 2021 15:08:12 GMT</pubDate>
    <dc:creator>Community Alums</dc:creator>
    <dc:date>2021-07-28T15:08:12Z</dc:date>
    <item>
      <title>How to Auto Populate email id of user in email field whose name is specified in Requested For field of a Request form.</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-auto-populate-email-id-of-user-in-email-field-whose-name/m-p/250777#M1971</link>
      <description>&lt;P&gt;How to Auto Populate email id of user in email field whose name is specified in Requested For field of a Request form.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 15:08:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-auto-populate-email-id-of-user-in-email-field-whose-name/m-p/250777#M1971</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2021-07-28T15:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Auto Populate email id of user in email field whose name is specified in Requested For field of a Request form.</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-auto-populate-email-id-of-user-in-email-field-whose-name/m-p/250778#M1972</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Create an onChange script&amp;nbsp;on requested for use below script.&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;unction onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    //Type appropriate comment here, and begin script below
    var user = g_form.getreference('requested_for', function(user) {// map the correct field
        g_form.setValue('u_email', user.email.toString());// map the correct field
    });
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you want to auto-populate the email id based on logged-in user the please line in the default value of the email id field&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;javascript: gs.getuser().getRecord().getValue('email);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jul 2021 15:13:59 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-auto-populate-email-id-of-user-in-email-field-whose-name/m-p/250778#M1972</guid>
      <dc:creator>BALAJI40</dc:creator>
      <dc:date>2021-07-28T15:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to Auto Populate email id of user in email field whose name is specified in Requested For field of a Request form.</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-auto-populate-email-id-of-user-in-email-field-whose-name/m-p/250779#M1973</link>
      <description>&lt;P&gt;&lt;SN-MENTION class="sn-mention" table="live_profile" sysid="5819830c1b1050dcd01143f6fe4bcb96"&gt;@RAJJYOTI&lt;/SN-MENTION&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to do via code you can try the code which is provided by @BALAJI&lt;/P&gt;
&lt;P&gt;else&lt;/P&gt;
&lt;P&gt;If you want to do via OOB future where no code required.&lt;/P&gt;
&lt;P&gt;then you can follow this article which is written by &lt;SN-MENTION class="sn-mention" table="live_profile" sysid="e5cf8aeddb181fc09c9ffb651f961930"&gt;@Mark Roethof&lt;/SN-MENTION&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;https://community.servicenow.com/community?id=community_article&amp;amp;sys_id=49deac8ddb92a010ab0202d5ca961967&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Let me know if still have any concerns&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Murthy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 16:14:05 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-auto-populate-email-id-of-user-in-email-field-whose-name/m-p/250779#M1973</guid>
      <dc:creator>Murthy Ch</dc:creator>
      <dc:date>2021-07-28T16:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to Auto Populate email id of user in email field whose name is specified in Requested For field of a Request form.</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-auto-populate-email-id-of-user-in-email-field-whose-name/m-p/250780#M1974</link>
      <description>&lt;P&gt;The code contains some typo's. Did you actually test this?&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;BR /&gt;Mark&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 16:22:14 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-auto-populate-email-id-of-user-in-email-field-whose-name/m-p/250780#M1974</guid>
      <dc:creator>Mark Roethof</dc:creator>
      <dc:date>2021-07-28T16:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to Auto Populate email id of user in email field whose name is specified in Requested For field of a Request form.</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-auto-populate-email-id-of-user-in-email-field-whose-name/m-p/250781#M1975</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the solution to this -&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Create a new client callable script include with following function&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;var UserDetails = Class.create();&lt;BR /&gt;UserDetails.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {&lt;/P&gt;
&lt;P&gt;getUserInfo: function() {&lt;BR /&gt; var details = {};&lt;BR /&gt; var userId = this.getParameter('sysparm_user_id');&lt;BR /&gt; var userObj = new GlideRecord('sys_user');&lt;BR /&gt; userObj.addQuery('sys_id', userId);&lt;BR /&gt; userObj.query();&lt;BR /&gt; if (userObj.next()) {&lt;BR /&gt;details.email= userObj.email_id.toString();&lt;BR /&gt; }&lt;BR /&gt; return JSON.stringify(details); &lt;BR /&gt; },&lt;/P&gt;
&lt;P&gt;type: 'UserDetails'&lt;/P&gt;
&lt;P&gt;});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Create a new catalog client script on the record producer/request form&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;function onChange(control, oldValue, newValue, isLoading) {&lt;BR /&gt; if (isLoading || newValue == '') {&lt;BR /&gt; return;&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; var ajax = new GlideAjax('UserDetails');&lt;BR /&gt; ajax.addParam('sysparm_name', 'getUserInfo');&lt;BR /&gt; ajax.addParam('sysparm_user_id', g_form.getValue('employee_name')); // change variable name here&lt;BR /&gt; ajax.getXML(doSomething);&lt;/P&gt;
&lt;P&gt;function doSomething(response) {&lt;BR /&gt; var answer = response.responseXML.documentElement.getAttribute("answer");&lt;BR /&gt; var answers = JSON.parse(answer);&lt;BR /&gt; g_form.setValue('var_email_id', answers.email.toString()); // change variable name here&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 03 Aug 2021 10:42:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-auto-populate-email-id-of-user-in-email-field-whose-name/m-p/250781#M1975</guid>
      <dc:creator>Harneet Sital</dc:creator>
      <dc:date>2021-08-03T10:42:29Z</dc:date>
    </item>
  </channel>
</rss>

