Issue with Catalog Client Script to set location

Kasia5
Tera Contributor

Hi All,

 

I have an issue with my Catalog Client Script related to set the location in Single Line Text variable based on user's location from another variable ('requested_for')

 

Currently it looks like:

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

    //Type appropriate comment here, and begin script below
    var affectedUser = g_form.getReference('requested_for', doAlert);

    function doAlert(affectedUser) {
        if (affectedUser) {
            g_form.setValue('requested_for_location', affectedUser.location);
        }
    }
}

 

and it was working fine my 'requested_for_location' field was a Reference field not a SIngle Line Text field.

When it is a Single Line Text filed then it gives me a sys_id value,,

Do you know how can I chnage the script to receive 'normal' string value in this Single Line Text field?

 

Thanks in advance for help!

6 REPLIES 6

@Peter Bodelier 

Thanks for informing

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Harish Bainsla
Kilo Patron
Kilo Patron

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


var affectedUser = g_form.getReference('requested_for', doAlert);

function doAlert(affectedUser) {
if (affectedUser) {

var location = affectedUser.location.getDisplayValue();
g_form.setValue('requested_for_location', location);
}
}
}