Trying to display user sap status catalogscript in variable set

asd22
Tera Contributor

Hello

 

i have a variable set with navn, ansattid, sap_status

 

You select a users Navn (name) from a reference field, then ansattid(id) gets autofilled with that users ID. Now i want sap status to also show, but im not getting it to work in my catalogscript. Please need some tips

 

 

asd22_0-1699616032149.png

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
    var userref = g_form.getReference('navn', userLookup);
    function userLookup(userref) {
        g_form.setValue('ansattid', userref.user_name);
        g_form.setValue('sap_status', userref.sap_active);

    }  
}

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@asd22 

you are using wrong field name it should be u_sap_active in this line

g_form.setValue('sap_status', userref.u_sap_active);

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@asd22 

you are using wrong field name it should be u_sap_active in this line

g_form.setValue('sap_status', userref.u_sap_active);

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

ah my mistake thanks