<?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 Guest Name being populated for some records in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/guest-name-being-populated-for-some-records/m-p/3461328#M1242753</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an inbound action for the guest emails to create a HR Case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The inbound action is the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {

    var usr = new GlideRecord('sys_user');
    usr.get(gs.getUserID());
	
	var guestTEST = gs.getProperty('sn_hr_core.inbound.guest.test');
	var guest =  gs.getProperty('sn_hr_core.inbound.guest');

    //Get OpCo
    var opco = new sn_hr_core.hr_ParentOpco().getOpco(gs.getUserID());
	//Get active HR Profile
	var hrProfileActive = new sn_hr_core.hr_Profile_Query().userHasProfile(gs.getUserID());

    var senderMail = email.from;
	
    //Set all basic HR fields 
    if (gs.getUserID() != guest &amp;amp;&amp;amp; opco == "Testing opco" &amp;amp;&amp;amp; hrProfileActive == true) {
        gs.eventQueue('sn_hr_core.hr.reply.email.test', null, recipientMail, senderMail);
        logger.log(" Sender (" + senderMail + ") is already present in the HR Services therefore hr query is not created");
        current.setAbortAction(true);
        return;
    } else {
        
		if (gs.getUserID() != guest) {
			current.watch_list = gs.getUserID();
        }
        
        var session = gs.getSession();
        session.impersonate(guestTEST);
        // Core email rules assign "Guest" if the from email does not match a user.
        // In this case, check the HR profile personal email, and reassing the case to that user.

        var profile;
      
        current.opened_by = guestTEST;
        current.opened_for = guestTEST;

        var bodyText = email.body_text;
        if (!bodyText)
            bodyText = email.body_html;
        var recipientMail = email.recipients;

        current.work_notes = "HR Case created by email:\n\nReceived from: " + email.origemail + "\n\n" + email.subject + "\n\n" + bodyText;
        current.description = bodyText;
        current.u_sender_email = email.origemail;
		
    }

    current.subject_person = current.opened_for;
    var newId = current.sys_id;
	
    gs.eventQueue('sn_hr_core_case.email.creation', current, newId, email.from);
})(current, event, email, logger, classifier);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue here is: I have a field called 'u_guest_name' that sometimes is being populated and sometimes is not.&lt;/P&gt;&lt;P&gt;Does someone know why is this happening?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jan 2026 10:07:16 GMT</pubDate>
    <dc:creator>rafas_10</dc:creator>
    <dc:date>2026-01-06T10:07:16Z</dc:date>
    <item>
      <title>Guest Name being populated for some records</title>
      <link>https://www.servicenow.com/community/developer-forum/guest-name-being-populated-for-some-records/m-p/3461328#M1242753</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an inbound action for the guest emails to create a HR Case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The inbound action is the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {

    var usr = new GlideRecord('sys_user');
    usr.get(gs.getUserID());
	
	var guestTEST = gs.getProperty('sn_hr_core.inbound.guest.test');
	var guest =  gs.getProperty('sn_hr_core.inbound.guest');

    //Get OpCo
    var opco = new sn_hr_core.hr_ParentOpco().getOpco(gs.getUserID());
	//Get active HR Profile
	var hrProfileActive = new sn_hr_core.hr_Profile_Query().userHasProfile(gs.getUserID());

    var senderMail = email.from;
	
    //Set all basic HR fields 
    if (gs.getUserID() != guest &amp;amp;&amp;amp; opco == "Testing opco" &amp;amp;&amp;amp; hrProfileActive == true) {
        gs.eventQueue('sn_hr_core.hr.reply.email.test', null, recipientMail, senderMail);
        logger.log(" Sender (" + senderMail + ") is already present in the HR Services therefore hr query is not created");
        current.setAbortAction(true);
        return;
    } else {
        
		if (gs.getUserID() != guest) {
			current.watch_list = gs.getUserID();
        }
        
        var session = gs.getSession();
        session.impersonate(guestTEST);
        // Core email rules assign "Guest" if the from email does not match a user.
        // In this case, check the HR profile personal email, and reassing the case to that user.

        var profile;
      
        current.opened_by = guestTEST;
        current.opened_for = guestTEST;

        var bodyText = email.body_text;
        if (!bodyText)
            bodyText = email.body_html;
        var recipientMail = email.recipients;

        current.work_notes = "HR Case created by email:\n\nReceived from: " + email.origemail + "\n\n" + email.subject + "\n\n" + bodyText;
        current.description = bodyText;
        current.u_sender_email = email.origemail;
		
    }

    current.subject_person = current.opened_for;
    var newId = current.sys_id;
	
    gs.eventQueue('sn_hr_core_case.email.creation', current, newId, email.from);
})(current, event, email, logger, classifier);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue here is: I have a field called 'u_guest_name' that sometimes is being populated and sometimes is not.&lt;/P&gt;&lt;P&gt;Does someone know why is this happening?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jan 2026 10:07:16 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/guest-name-being-populated-for-some-records/m-p/3461328#M1242753</guid>
      <dc:creator>rafas_10</dc:creator>
      <dc:date>2026-01-06T10:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Guest Name being populated for some records</title>
      <link>https://www.servicenow.com/community/developer-forum/guest-name-being-populated-for-some-records/m-p/3461341#M1242754</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/456930"&gt;@rafas_10&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;One thing to check is your use of current.setAbortAction(true) in the inbound action.&lt;/P&gt;&lt;P&gt;When setAbortAction(true) is executed, the record insert is stopped immediately. This means that any &lt;STRONG&gt;before-insert Business Rules, HR Core logic, or dictionary defaults&lt;/STRONG&gt; that normally populate fields (like u_guest_name) will &lt;STRONG&gt;not run&lt;/STRONG&gt;. As a result, depending on whether this condition is met, the field may sometimes be populated and sometimes not.&lt;/P&gt;&lt;P&gt;If you need u_guest_name to be consistent, the safest approach is to &lt;STRONG&gt;explicitly set it in the inbound action&lt;/STRONG&gt; before aborting or avoid aborting the insert if downstream logic is required.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, and if this helps, please mark the comment as &lt;STRONG&gt;Helpful&lt;/STRONG&gt; so others with the same issue can find it more easily. &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jan 2026 10:26:11 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/guest-name-being-populated-for-some-records/m-p/3461341#M1242754</guid>
      <dc:creator>kaustubhdub</dc:creator>
      <dc:date>2026-01-06T10:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Guest Name being populated for some records</title>
      <link>https://www.servicenow.com/community/developer-forum/guest-name-being-populated-for-some-records/m-p/3461343#M1242755</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/456930"&gt;@rafas_10&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;your inbound action script is not populating that field "u_guest_name" as there is no line for that.&lt;/P&gt;
&lt;P&gt;Seems some other custom logic is populating and that has an issue.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":light_bulb:"&gt;💡&lt;/span&gt; If my response helped, please mark it as correct &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; and close the thread &lt;span class="lia-unicode-emoji" title=":locked:"&gt;🔒&lt;/span&gt;— this helps future readers find the solution faster! &lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jan 2026 10:26:59 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/guest-name-being-populated-for-some-records/m-p/3461343#M1242755</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2026-01-06T10:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Guest Name being populated for some records</title>
      <link>https://www.servicenow.com/community/developer-forum/guest-name-being-populated-for-some-records/m-p/3461372#M1242761</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/456930"&gt;@rafas_10&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After checking the inbound action, I noticed that &lt;STRONG&gt;u_guest_name is never explicitly populated in the script&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;The field gets filled only when ServiceNow is able to extract a &lt;STRONG&gt;sender display name from the inbound email&lt;/STRONG&gt;. For guest emails, this depends on the email format:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Emails with a display name (e.g., John Doe &amp;lt;john.doe@gmail.com&amp;gt;) → u_guest_name is populated.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Emails with only an email address → no sender name → field remains empty.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So the behavior is expected and driven by email headers, not by the inbound action logic.&lt;BR /&gt;To make it consistent, we can add a small fallback to populate u_guest_name using the sender name or email address.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;(&lt;SPAN class=""&gt;function&lt;/SPAN&gt; &lt;SPAN class=""&gt;runAction&lt;/SPAN&gt;(&lt;SPAN class=""&gt; &lt;SPAN class=""&gt;/*GlideRecord*/&lt;/SPAN&gt;&lt;/SPAN&gt; current, &lt;SPAN class=""&gt;/*GlideRecord*/&lt;/SPAN&gt; event, &lt;SPAN class=""&gt;/*EmailWrapper*/&lt;/SPAN&gt; email, &lt;SPAN class=""&gt;/*ScopedEmailLogger*/&lt;/SPAN&gt; logger, &lt;SPAN class=""&gt;/*EmailClassifier*/&lt;/SPAN&gt; classifier) {

    &lt;SPAN class=""&gt;var&lt;/SPAN&gt; usr = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;GlideRecord&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'sys_user'&lt;/SPAN&gt;);
    usr.&lt;SPAN class=""&gt;get&lt;/SPAN&gt;(gs.&lt;SPAN class=""&gt;getUserID&lt;/SPAN&gt;());&lt;BR /&gt;&lt;SPAN class=""&gt;    var&lt;/SPAN&gt; guestTEST = gs.&lt;SPAN class=""&gt;getProperty&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'sn_hr_core.inbound.guest.test'&lt;/SPAN&gt;);&lt;BR /&gt;&lt;SPAN class=""&gt;    var&lt;/SPAN&gt; guest =  gs.&lt;SPAN class=""&gt;getProperty&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'sn_hr_core.inbound.guest'&lt;/SPAN&gt;);

    &lt;SPAN class=""&gt;//Get OpCo&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;var&lt;/SPAN&gt; opco = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; sn_hr_core.&lt;SPAN class=""&gt;hr_ParentOpco&lt;/SPAN&gt;().&lt;SPAN class=""&gt;getOpco&lt;/SPAN&gt;(gs.&lt;SPAN class=""&gt;getUserID&lt;/SPAN&gt;());
&lt;SPAN class=""&gt;   //Get active HR Profile&lt;/SPAN&gt;
&lt;SPAN class=""&gt;    var&lt;/SPAN&gt; hrProfileActive = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; sn_hr_core.&lt;SPAN class=""&gt;hr_Profile_Query&lt;/SPAN&gt;().&lt;SPAN class=""&gt;userHasProfile&lt;/SPAN&gt;(gs.&lt;SPAN class=""&gt;getUserID&lt;/SPAN&gt;());
    &lt;SPAN class=""&gt;var&lt;/SPAN&gt; senderMail = email.&lt;SPAN class=""&gt;from&lt;/SPAN&gt;;&lt;BR /&gt;
    &lt;SPAN class=""&gt;//Set all basic HR fields &lt;/SPAN&gt;
    &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (gs.&lt;SPAN class=""&gt;getUserID&lt;/SPAN&gt;() != guest &amp;amp;&amp;amp; opco == &lt;SPAN class=""&gt;"Testing opco"&lt;/SPAN&gt; &amp;amp;&amp;amp; hrProfileActive == &lt;SPAN class=""&gt;true&lt;/SPAN&gt;) {
        gs.&lt;SPAN class=""&gt;eventQueue&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'sn_hr_core.hr.reply.email.test'&lt;/SPAN&gt;, &lt;SPAN class=""&gt;null&lt;/SPAN&gt;, recipientMail, senderMail);
        logger.&lt;SPAN class=""&gt;log&lt;/SPAN&gt;(&lt;SPAN class=""&gt;" Sender ("&lt;/SPAN&gt; + senderMail + &lt;SPAN class=""&gt;") is already present in the HR Services therefore hr query is not created"&lt;/SPAN&gt;);
        current.&lt;SPAN class=""&gt;setAbortAction&lt;/SPAN&gt;(&lt;SPAN class=""&gt;true&lt;/SPAN&gt;);
        &lt;SPAN class=""&gt;return&lt;/SPAN&gt;;
    } &lt;SPAN class=""&gt;else&lt;/SPAN&gt; {
        
		&lt;SPAN class=""&gt;if&lt;/SPAN&gt; (gs.&lt;SPAN class=""&gt;getUserID&lt;/SPAN&gt;() != guest) {
			current.&lt;SPAN class=""&gt;watch_list&lt;/SPAN&gt; = gs.&lt;SPAN class=""&gt;getUserID&lt;/SPAN&gt;();
        }
        
        &lt;SPAN class=""&gt;var&lt;/SPAN&gt; session = gs.&lt;SPAN class=""&gt;getSession&lt;/SPAN&gt;();
        session.&lt;SPAN class=""&gt;impersonate&lt;/SPAN&gt;(guestTEST);
        current.&lt;SPAN class=""&gt;opened_by&lt;/SPAN&gt; = guestTEST;
        current.&lt;SPAN class=""&gt;opened_for&lt;/SPAN&gt; = guestTEST;
        &lt;SPAN class=""&gt;var&lt;/SPAN&gt; bodyText = email.&lt;SPAN class=""&gt;body_text&lt;/SPAN&gt;;
        &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (!bodyText)
            bodyText = email.&lt;SPAN class=""&gt;body_html&lt;/SPAN&gt;;
        &lt;SPAN class=""&gt;var&lt;/SPAN&gt; recipientMail = email.&lt;SPAN class=""&gt;recipients&lt;/SPAN&gt;;
        current.&lt;SPAN class=""&gt;work_notes&lt;/SPAN&gt; = &lt;SPAN class=""&gt;"HR Case created by email:\n\nReceived from: "&lt;/SPAN&gt; + email.&lt;SPAN class=""&gt;origemail&lt;/SPAN&gt; + &lt;SPAN class=""&gt;"\n\n"&lt;/SPAN&gt; + email.&lt;SPAN class=""&gt;subject&lt;/SPAN&gt; + &lt;SPAN class=""&gt;"\n\n"&lt;/SPAN&gt; + bodyText;
        current.&lt;SPAN class=""&gt;description&lt;/SPAN&gt; = bodyText;
        current.&lt;SPAN class=""&gt;u_sender_email&lt;/SPAN&gt; = email.&lt;SPAN class=""&gt;origemail&lt;/SPAN&gt;;

        &lt;SPAN class=""&gt;//  Fallback logic added for consistent guest name population&lt;/SPAN&gt;
        &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (!current.&lt;SPAN class=""&gt;u_guest_name&lt;/SPAN&gt;) {
            current.&lt;SPAN class=""&gt;u_guest_name&lt;/SPAN&gt; = email.&lt;SPAN class=""&gt;from_name&lt;/SPAN&gt; || email.&lt;SPAN class=""&gt;from&lt;/SPAN&gt;;
        }
    }

    current.&lt;SPAN class=""&gt;subject_person&lt;/SPAN&gt; = current.&lt;SPAN class=""&gt;opened_for&lt;/SPAN&gt;;
    &lt;SPAN class=""&gt;var&lt;/SPAN&gt; newId = current.&lt;SPAN class=""&gt;sys_id&lt;/SPAN&gt;;
	
    gs.&lt;SPAN class=""&gt;eventQueue&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'sn_hr_core_case.email.creation'&lt;/SPAN&gt;, current, newId, email.&lt;SPAN class=""&gt;from&lt;/SPAN&gt;);

})(current, event, email, logger, classifier);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;If you find this reply as useful please mark it as helpful and accept my solution&lt;span class="lia-unicode-emoji" title=":smiling_face_with_halo:"&gt;😇&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jan 2026 10:50:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/guest-name-being-populated-for-some-records/m-p/3461372#M1242761</guid>
      <dc:creator>sivasankaris</dc:creator>
      <dc:date>2026-01-06T10:50:48Z</dc:date>
    </item>
  </channel>
</rss>

