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