<?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: Having issue with Before business rule not populating fields on incident form in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3061660#M1149915</link>
    <description>&lt;P&gt;Hi Rhonda,&lt;/P&gt;
&lt;P&gt;I can see that the script is not running because your condition is never true.&amp;nbsp; Service offering is a reference field, and as such stores the sys_id of the record as it's value.&amp;nbsp; You can select the name using Filter conditions, or change your condition to&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt; current.service_offering.name == 'ACD' || current.service_offering.name == 'Call Center'&lt;/LI-CODE&gt;
&lt;P&gt;In the script, you can dot-walk to the caller's location's support so no GlideRecords are needed&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;function executeRule(current, previous /*null when async*/ ) {

    // Check if the affected user (caller_id) is set
    if (current.caller_id) {
		if (current.caller_id.location) {
			if (current.caller_id.location.u_location_support) {
				// Set the Assignment Group field to the location's Location Support
				current.assignment_group = current.caller_id.location.u_location_support;
                // Set the Assigned To field to the location's Assignment Group
                current.assigned_to = current.caller_id.location.u_assignment_group;
            }
        }
    }
})(current, previous);&lt;/LI-CODE&gt;
&lt;P&gt;The last line doesn't make sense - assigned_to is a person, and location.u_assignment_group sounds like a group&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Oct 2024 19:33:18 GMT</pubDate>
    <dc:creator>Brad Bowman</dc:creator>
    <dc:date>2024-10-01T19:33:18Z</dc:date>
    <item>
      <title>Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3061584#M1149909</link>
      <description>&lt;P&gt;Hello, I created a business rule that is not working as expected.&amp;nbsp; &amp;nbsp;I was asked to auto assign incidents if the service offering is "acd" or "call center" on the UI side to the affected user's location location support&amp;nbsp; to the Assigned to field and the location assignment group to the assignment group field fore saving the form.&amp;nbsp; What am I doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;Insert and update is checked&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;condition :&amp;nbsp; &amp;nbsp;&amp;nbsp;current.service_offering == 'ACD' || current.service_offering == 'Call Center'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;(function executeRule(current, previous /*null when async*/) {&lt;/P&gt;&lt;P&gt;// Check if the affected user (caller_id) is set&lt;BR /&gt;if (current.caller_id) {&lt;BR /&gt;// Fetch the affected user's record&lt;BR /&gt;var userGr = new GlideRecord('sys_user');&lt;BR /&gt;if (userGr.get(current.caller_id)) {&lt;BR /&gt;// Get the user's location&lt;BR /&gt;var userLocation = userGr.location; // Assuming this is the field for location&lt;BR /&gt;&lt;BR /&gt;// Fetch the location record&lt;BR /&gt;var locationGr = new GlideRecord('cmn_location');&lt;BR /&gt;if (locationGr.get(userLocation)) {&lt;BR /&gt;// Set the Assignment Group field to the location's Location Support&lt;BR /&gt;current.assignment_group = locationGr.u_location_support; // Adjust field name if necessary&lt;/P&gt;&lt;P&gt;// Set the Assigned To field to the location's Assignment Group&lt;BR /&gt;current.assigned_to = locationGr.u_assignment_group; // Adjust field name if necessary&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;})(current, previous);&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 18:59:52 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3061584#M1149909</guid>
      <dc:creator>Rhonda9</dc:creator>
      <dc:date>2024-10-01T18:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3061660#M1149915</link>
      <description>&lt;P&gt;Hi Rhonda,&lt;/P&gt;
&lt;P&gt;I can see that the script is not running because your condition is never true.&amp;nbsp; Service offering is a reference field, and as such stores the sys_id of the record as it's value.&amp;nbsp; You can select the name using Filter conditions, or change your condition to&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt; current.service_offering.name == 'ACD' || current.service_offering.name == 'Call Center'&lt;/LI-CODE&gt;
&lt;P&gt;In the script, you can dot-walk to the caller's location's support so no GlideRecords are needed&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;function executeRule(current, previous /*null when async*/ ) {

    // Check if the affected user (caller_id) is set
    if (current.caller_id) {
		if (current.caller_id.location) {
			if (current.caller_id.location.u_location_support) {
				// Set the Assignment Group field to the location's Location Support
				current.assignment_group = current.caller_id.location.u_location_support;
                // Set the Assigned To field to the location's Assignment Group
                current.assigned_to = current.caller_id.location.u_assignment_group;
            }
        }
    }
})(current, previous);&lt;/LI-CODE&gt;
&lt;P&gt;The last line doesn't make sense - assigned_to is a person, and location.u_assignment_group sounds like a group&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 19:33:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3061660#M1149915</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2024-10-01T19:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3061665#M1149916</link>
      <description>&lt;P&gt;Thank you for your reply, I tried the script that you shared but it is not allowing me to save.&amp;nbsp; &amp;nbsp;Oh you are right about the last line, it should ....&amp;nbsp; &amp;nbsp; &amp;nbsp;Also, I cant save the script you shared with me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt; executeRule(current, previous &lt;/SPAN&gt;&lt;SPAN&gt;/*null when async*/&lt;/SPAN&gt;&lt;SPAN&gt; ) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Check if the affected user (caller_id) is set&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (current.caller_id) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (current.caller_id.location) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (current.caller_id.location.u_location_support) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Set the Assignment Group field to the location's Location Support&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;current.assignment_to&lt;/STRONG&gt; = current.caller_id.location.u_location_support;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Set the Assigned To field to the location's Assignment Group&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c&lt;STRONG&gt;urrent.u_assignment_group&lt;/STRONG&gt; = current.caller_id.location.u_assignment_group;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;})(current, previous);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 01 Oct 2024 19:44:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3061665#M1149916</guid>
      <dc:creator>Rhonda9</dc:creator>
      <dc:date>2024-10-01T19:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3061753#M1149937</link>
      <description>&lt;P&gt;The script is working but only after the assignment group is already populated and I save the incident.&amp;nbsp; I want the automation to happen before saving.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 21:51:57 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3061753#M1149937</guid>
      <dc:creator>Rhonda9</dc:creator>
      <dc:date>2024-10-01T21:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062070#M1150003</link>
      <description>&lt;P&gt;A Business Rule will run before or after insert/update - that really means before the database action, so you need to submit/save the record either way.&amp;nbsp; It sounds like you want to see the Assigned to and Assignment group fields populate &lt;EM&gt;on the form&lt;/EM&gt; &lt;EM&gt;when&lt;/EM&gt; the Service offering field is &lt;EM&gt;populated or changes&lt;/EM&gt;.&amp;nbsp; To do this you will need an onChange Client Script.&amp;nbsp; Client scripts can't dot-walk to related fields, so your onChange Client Script will need to use GlideAjax to call a Script Include.&amp;nbsp; This is an often-used tool to have in your belt.&amp;nbsp; Here is an excellent guide on how to do this.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2323817" target="_blank" rel="noopener"&gt;https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2323817&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; In your case If the newValue (service offering sys_id) is one of the two that belong to ACD or Call Center, you will pass in the caller_id as a parameter.&amp;nbsp; The Script Include will run the GlideRecord from your first attempt and return the two custom fields for the client script to set on the form.&amp;nbsp; Give the scripts a try, and if you're stuck post each script using the insert code icon &amp;lt;/&amp;gt; and we'll get it sorted.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 10:39:05 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062070#M1150003</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2024-10-02T10:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062101#M1150010</link>
      <description>&lt;P&gt;Thank you for the resources...&lt;/P&gt;&lt;P&gt;This is what I have and it's still not working for me:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Client Script&lt;/STRONG&gt; with service offering being the onChange field Name&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt; onChange(control, oldValue, newValue, isLoading) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Check if the form is loading or if no new value is selected&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (isLoading || !newValue) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;alert(&lt;/SPAN&gt;&lt;SPAN&gt;'This is an alert message.'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Check if the selected value is "ACD" or "Call Center"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (newValue === &lt;/SPAN&gt;&lt;SPAN&gt;'ACD'&lt;/SPAN&gt;&lt;SPAN&gt; || newValue === &lt;/SPAN&gt;&lt;SPAN&gt;'Call Center'&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; locationSysId = g_form.getValue(&lt;/SPAN&gt;&lt;SPAN&gt;'location'&lt;/SPAN&gt;&lt;SPAN&gt;); &lt;/SPAN&gt;&lt;SPAN&gt;// Get the location field value&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Ensure the location field is not empty&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (locationSysId) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Call the Script Include&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; ga = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;GlideAjax&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'LocationUtils'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.addParam(&lt;/SPAN&gt;&lt;SPAN&gt;'sysparm_name'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'getLocationDetails'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.addParam(&lt;/SPAN&gt;&lt;SPAN&gt;'sysparm_location_id'&lt;/SPAN&gt;&lt;SPAN&gt;, locationSysId);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.getXMLAnswer(&lt;/SPAN&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt;(response) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Parse the response&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; result = &lt;/SPAN&gt;&lt;SPAN&gt;JSON&lt;/SPAN&gt;&lt;SPAN&gt;.parse(response);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (result) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Set the Assignment Group and Assigned To fields&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setValue(&lt;/SPAN&gt;&lt;SPAN&gt;'assignment_group'&lt;/SPAN&gt;&lt;SPAN&gt;, result.u_assignment_group);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setValue(&lt;/SPAN&gt;&lt;SPAN&gt;'assigned_to'&lt;/SPAN&gt;&lt;SPAN&gt;, result.u_assigned_to);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.addErrorMessage(&lt;/SPAN&gt;&lt;SPAN&gt;'Could not retrieve location details.'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.addErrorMessage(&lt;/SPAN&gt;&lt;SPAN&gt;'Please select a location.'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Script Include&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt; onChange(control, oldValue, newValue, isLoading) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (isLoading || !newValue) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Call the Script Include if the service offering is ACD or Call Center&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (newValue === &lt;/SPAN&gt;&lt;SPAN&gt;'ACD'&lt;/SPAN&gt;&lt;SPAN&gt; || newValue === &lt;/SPAN&gt;&lt;SPAN&gt;'Call Center'&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; locationSysId = g_form.getValue(&lt;/SPAN&gt;&lt;SPAN&gt;'location'&lt;/SPAN&gt;&lt;SPAN&gt;); &lt;/SPAN&gt;&lt;SPAN&gt;// Get the location field value&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (locationSysId) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Create a GlideAjax instance&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; ga = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;GlideAjax&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'LocationUtils'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.addParam(&lt;/SPAN&gt;&lt;SPAN&gt;'sysparm_name'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'getLocationDetails'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.addParam(&lt;/SPAN&gt;&lt;SPAN&gt;'sysparm_location_id'&lt;/SPAN&gt;&lt;SPAN&gt;, locationSysId);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.getXMLAnswer(&lt;/SPAN&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt;(response) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; result = &lt;/SPAN&gt;&lt;SPAN&gt;JSON&lt;/SPAN&gt;&lt;SPAN&gt;.parse(response);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (result) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Set the Assignment Group and Assigned To fields&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setValue(&lt;/SPAN&gt;&lt;SPAN&gt;'assignment_group'&lt;/SPAN&gt;&lt;SPAN&gt;, result.u_assignment_group);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setValue(&lt;/SPAN&gt;&lt;SPAN&gt;'assigned_to'&lt;/SPAN&gt;&lt;SPAN&gt;, result.u_assigned_to);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.addErrorMessage(&lt;/SPAN&gt;&lt;SPAN&gt;'Could not retrieve location details.'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.addErrorMessage(&lt;/SPAN&gt;&lt;SPAN&gt;'Please select a location.'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 02 Oct 2024 11:23:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062101#M1150010</guid>
      <dc:creator>Rhonda9</dc:creator>
      <dc:date>2024-10-02T11:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062120#M1150014</link>
      <description>&lt;P&gt;You need to use the sys_id of the service offering, not the name since this is a reference field the value is a sys_id.&amp;nbsp; I've changed your alert to show you the value of the service offering selected.&amp;nbsp; In your first script you were getting the location of the caller, this script is getting the incident location.&amp;nbsp; If this change was intended the rest of the client script should be fine.&amp;nbsp; Added an alert on response to confirm that is the expected value.&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;function onChange(control, oldValue, newValue, isLoading) {
    // Check if the form is loading or if no new value is selected
    if (isLoading || !newValue) {
        return;
    }
    alert('Service offering = ' + newValue);
    // Check if the selected value is "ACD" or "Call Center"
    if (newValue === 'sys_id' || newValue === 'sys_id') {
        var locationSysId = g_form.getValue('location'); // Get the location field value

        // Ensure the location field is not empty
        if (locationSysId) {
            // Call the Script Include
            var ga = new GlideAjax('LocationUtils');
            ga.addParam('sysparm_name', 'getLocationDetails');
            ga.addParam('sysparm_location_id', locationSysId);
            ga.getXMLAnswer(function(response) {
                alert(response);
                // Parse the response
                var result = JSON.parse(response);
                if (result) {
                    // Set the Assignment Group and Assigned To fields
                    g_form.setValue('assignment_group', result.u_assignment_group);
                    g_form.setValue('assigned_to', result.u_assigned_to);
                } else {
                    g_form.addErrorMessage('Could not retrieve location details.');
                }
            });
        } else {
            g_form.addErrorMessage('Please select a location.');
        }
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;If it's still not working post the Script Include (client script was posted twice above)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 12:04:37 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062120#M1150014</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2024-10-02T12:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062129#M1150017</link>
      <description>&lt;P&gt;Correct the trigger condition ..seems like service offering is reference field..&lt;/P&gt;&lt;P&gt;So correct the condition like current.service_offering.getDisplayValue()=='ACD' || current.service_offering.name=='ACD'&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 12:25:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062129#M1150017</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-10-02T12:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062138#M1150020</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp; I copied your script and added the sys id's and&amp;nbsp; I am now&amp;nbsp; getting the message&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;Could not retrieve location details".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is the Script Include&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt; onChange(control, oldValue, newValue, isLoading) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (isLoading || !newValue) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Call the Script Include if the service offering is ACD or Call Center&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (newValue === &lt;/SPAN&gt;&lt;SPAN&gt;'ACD'&lt;/SPAN&gt;&lt;SPAN&gt; || newValue === &lt;/SPAN&gt;&lt;SPAN&gt;'Call Center'&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; locationSysId = g_form.getValue(&lt;/SPAN&gt;&lt;SPAN&gt;'location'&lt;/SPAN&gt;&lt;SPAN&gt;); &lt;/SPAN&gt;&lt;SPAN&gt;// Get the location field value&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (locationSysId) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Create a GlideAjax instance&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; ga = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;GlideAjax&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'LocationUtils'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.addParam(&lt;/SPAN&gt;&lt;SPAN&gt;'sysparm_name'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'getLocationDetails'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.addParam(&lt;/SPAN&gt;&lt;SPAN&gt;'sysparm_location_id'&lt;/SPAN&gt;&lt;SPAN&gt;, locationSysId);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.getXMLAnswer(&lt;/SPAN&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt;(response) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; result = &lt;/SPAN&gt;&lt;SPAN&gt;JSON&lt;/SPAN&gt;&lt;SPAN&gt;.parse(response);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (result) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Set the Assignment Group and Assigned To fields&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setValue(&lt;/SPAN&gt;&lt;SPAN&gt;'assignment_group'&lt;/SPAN&gt;&lt;SPAN&gt;, result.u_assignment_group);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setValue(&lt;/SPAN&gt;&lt;SPAN&gt;'assigned_to'&lt;/SPAN&gt;&lt;SPAN&gt;, result.u_assigned_to);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.addErrorMessage(&lt;/SPAN&gt;&lt;SPAN&gt;'Could not retrieve location details.'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.addErrorMessage(&lt;/SPAN&gt;&lt;SPAN&gt;'Please select a location.'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 02 Oct 2024 12:35:23 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062138#M1150020</guid>
      <dc:creator>Rhonda9</dc:creator>
      <dc:date>2024-10-02T12:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062139#M1150021</link>
      <description>&lt;P&gt;The (old) Client Script still re-posted.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 12:38:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062139#M1150021</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2024-10-02T12:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062145#M1150023</link>
      <description>&lt;P&gt;Okay, I think I accidently copied the client script into the Script Include.&lt;/P&gt;&lt;P&gt;Here it is....&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;LocationUtils&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;Class&lt;/SPAN&gt;&lt;SPAN&gt;.create();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;LocationUtils&lt;/SPAN&gt;&lt;SPAN&gt;.prototype = {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; initialize: &lt;/SPAN&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt;() {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; },&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// This function is callable from the client script&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; getLocationDetails: &lt;/SPAN&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt;() {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; locationId = &lt;/SPAN&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.getParameter(&lt;/SPAN&gt;&lt;SPAN&gt;'sysparm_location_id'&lt;/SPAN&gt;&lt;SPAN&gt;); &lt;/SPAN&gt;&lt;SPAN&gt;// Get the location sys_id&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; locationGr = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;GlideRecord&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'cmn_location'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (locationGr.&lt;/SPAN&gt;&lt;SPAN&gt;get&lt;/SPAN&gt;&lt;SPAN&gt;(locationId)) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Create an object to hold the results&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; result = {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; assignment_group: locationGr.u_assignment_group, &lt;/SPAN&gt;&lt;SPAN&gt;// Adjust field name as necessary&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; assigned_to: locationGr.u_location_support &lt;/SPAN&gt;&lt;SPAN&gt;// Adjust field name as necessary&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;JSON&lt;/SPAN&gt;&lt;SPAN&gt;.stringify(result); &lt;/SPAN&gt;&lt;SPAN&gt;// Return the result as a JSON string&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;JSON&lt;/SPAN&gt;&lt;SPAN&gt;.stringify(&lt;/SPAN&gt;&lt;SPAN&gt;null&lt;/SPAN&gt;&lt;SPAN&gt;); &lt;/SPAN&gt;&lt;SPAN&gt;// Return null if not found&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; },&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; type: &lt;/SPAN&gt;&lt;SPAN&gt;'LocationUtils'&lt;/SPAN&gt; &lt;SPAN&gt;// Ensures the class is identified as 'LocationUtils'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;};&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;// Allow the Script Include to be callable from the client&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;// Ensure that the "Client Callable" checkbox is checked in the Script Include record&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 02 Oct 2024 12:43:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062145#M1150023</guid>
      <dc:creator>Rhonda9</dc:creator>
      <dc:date>2024-10-02T12:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062174#M1150026</link>
      <description>&lt;P&gt;If the Client callable box is checked after text is entered in the Script box, it does not update the script appropriately - making it client callable.&amp;nbsp; Here's what yours should look like.&amp;nbsp; I would get in the habit of always returning something, so it avoids browser errors and is easier to troubleshoot - I'm not getting a response, did my Script Include run, or just not return anything?&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var LocationUtils = Class.create();
LocationUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    // This function is callable from the client script
    getLocationDetails: function() {
        var locationId = this.getParameter('sysparm_location_id'); // Get the location sys_id
        var locationGr = new GlideRecord('cmn_location');

        if (locationGr.get(locationId)) {
            // Create an object to hold the results
            var result = {
                assignment_group: locationGr.u_assignment_group, // Adjust field name as necessary
                assigned_to: locationGr.u_location_support // Adjust field name as necessary
            };
            return JSON.stringify(result); // Return the result as a JSON string
        }

        return 'location not found'; // Return if not found
    },

    type: 'LocationUtils'
});&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 12:51:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062174#M1150026</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2024-10-02T12:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062181#M1150027</link>
      <description>&lt;P&gt;I did not get anything this time..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 13:00:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062181#M1150027</guid>
      <dc:creator>Rhonda9</dc:creator>
      <dc:date>2024-10-02T13:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062199#M1150031</link>
      <description>&lt;P&gt;Adding some temporary logs to see if the script is running, and how far it is getting.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var LocationUtils = Class.create();
LocationUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    // This function is callable from the client script
    getLocationDetails: function() {
        gs.addInfoMessage('Script Include running')
        var locationId = this.getParameter('sysparm_location_id'); // Get the location sys_id
        gs.addInfoMessage('Location = ' + locationId)
        var locationGr = new GlideRecord('cmn_location');
        if (locationGr.get(locationId)) {
            gs.addInfoMessage('Location record found')
            // Create an object to hold the results
            var result = {
                assignment_group: locationGr.u_assignment_group, // Adjust field name as necessary
                assigned_to: locationGr.u_location_support // Adjust field name as necessary
            };
            gs.addInfoMessage('Result = ' + JSON.stringify(result))
            return JSON.stringify(result); // Return the result as a JSON string
        }
        gs.addInfoMessage('Location record not found')
        return 'location not found'; // Return if not found
    },

    type: 'LocationUtils'
});&lt;/LI-CODE&gt;
&lt;P&gt;Which of these messages are you seeing when you change Service Offering to ACD or Call Center after ensuring the Location field is populated?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 13:13:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062199#M1150031</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2024-10-02T13:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062225#M1150035</link>
      <description>&lt;P&gt;This is what I am getting....&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rhonda9_0-1727875746523.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/391189i215C70656111709E/image-size/medium?v=v2&amp;amp;px=400" srcset="/community/image/serverpage/image-id/391189i215C70656111709E/image-size/medium?v=v2&amp;amp;px=400 1.0x" role="button" title="Rhonda9_0-1727875746523.png" alt="Rhonda9_0-1727875746523.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 13:29:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062225#M1150035</guid>
      <dc:creator>Rhonda9</dc:creator>
      <dc:date>2024-10-02T13:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062234#M1150038</link>
      <description>&lt;P&gt;Still making progress - almost there.&amp;nbsp; If these are the correct custom field names on the location table, you need to force the sys_ids/values to a string type.&amp;nbsp; Here are two methods for doing that&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;assignment_group: locationGr.u_assignment_group.toString(), // Adjust field name as necessary
assigned_to: locationGr.getValue('u_location_support')&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 13:39:27 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062234#M1150038</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2024-10-02T13:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062249#M1150040</link>
      <description>&lt;P&gt;Wow...it is working... Thank you so much for your help. I really appreciate you staying with me on this.&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 13:47:21 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062249#M1150040</guid>
      <dc:creator>Rhonda9</dc:creator>
      <dc:date>2024-10-02T13:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Having issue with Before business rule not populating fields on incident form</title>
      <link>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062314#M1150052</link>
      <description>&lt;P&gt;You are welcome!&amp;nbsp; I'm happy to help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="comic sans ms,sans-serif" size="2"&gt;Connect with me &lt;A href="https://www.linkedin.com/in/brad-bowman-321b1567/" target="_blank" rel="noopener"&gt;https://www.linkedin.com/in/brad-bowman-321b1567/&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 14:59:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/having-issue-with-before-business-rule-not-populating-fields-on/m-p/3062314#M1150052</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2024-10-02T14:59:18Z</dc:date>
    </item>
  </channel>
</rss>

