Thank you,  I copied your script and added the sys id's and  I am now  getting the message "Could not retrieve location details".

Here is the Script Include

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || !newValue) {
        return;
    }

    // Call the Script Include if the service offering is ACD or Call Center
    if (newValue === 'ACD' || newValue === 'Call Center') {
        var locationSysId = g_form.getValue('location'); // Get the location field value

        if (locationSysId) {
            // Create a GlideAjax instance
            var ga = new GlideAjax('LocationUtils');
            ga.addParam('sysparm_name', 'getLocationDetails');
            ga.addParam('sysparm_location_id', locationSysId);
            ga.getXMLAnswer(function(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.');
        }
    }
}

The (old) Client Script still re-posted.

Okay, I think I accidently copied the client script into the Script Include.

Here it is....

var LocationUtils = Class.create();
LocationUtils.prototype = {
    initialize: function() {
    },

    // 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 JSON.stringify(null); // Return null if not found
    },

    type: 'LocationUtils' // Ensures the class is identified as 'LocationUtils'
};

// Allow the Script Include to be callable from the client
// Ensure that the "Client Callable" checkbox is checked in the Script Include record

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.  Here's what yours should look like.  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?

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'
});

 

I did not get anything this time..