copied a variable set, and added a new tittle. notworking

asd22
Tera Contributor

Hello.

 

I have a variable set with name(refrence field to user), ID (singel line text).

and a catalog script that gets the ID of the selected. I copied this since i was asked to. And just added a new tittle and now the catalog script is not working, what may the issue be? I have tried everything i can.

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    var userref = g_form.getReference('name', userLookup);
    function userLookup(userref) {
        g_form.setValue('id', userref.user_name);
    }
}
1 ACCEPTED SOLUTION

Not the script type. You need to select another variable name onChange of which this client script is running   and then revert that back . Reason being system stores sys_id of the variable and its still storing the sys_id of the variable that is part of the old variable set.

Gurpreet07_0-1699610193269.png

 

 

View solution in original post

6 REPLIES 6

asd22
Tera Contributor

Not sure if this helps to figure it out:

asd22_1-1699609595105.png

 

asd22_0-1699609580213.png

 

Anurag Tripathi
Mega Patron
Mega Patron

Script looks fine, 

Can you run this and show what you get in the alerts

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
alert(g_form.getValue('name');
    var userref = g_form.getReference('name', userLookup);
    function userLookup(userref) {
alert(userref.user_name);
        g_form.setValue('id', userref.user_name);
    }
}

 

-Anurag