Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get information from one variable set to another

asd22
Tera Contributor

Hello.

 

Im making a catalog item, that is gonna be used to look up users in a reference field. Then when you select a user his/hers information will auto populate the fields in the catalog item.

Variable set A, that's where the user basic information gets collected, Here i select the name and the users ID, status gets auto inserted into fields.

 

Then i have Variable set B. Here i have "account expire date", where i want the users account expire date to be auto filled in. The only issue, i need to get variable set B to notice when variable set A gets changed, how do i do this?

 

This are my current catalog client scripts:
Variable set A 

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





 

Variable set B

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
    var userref = g_form.getValue('varA_name', userLookup);
    function userLookup(userref) {
        g_form.setValue('varB_accountexp, userref.account_expires);



    }  
}
2 REPLIES 2

Jack Littlewort
Giga Guru

Hi @asd22 

 

You will need your client script to be on the catalog item which has the variable sets linked to it.

so i should move both client scripts out of their variable set, and have them as client script on the catalog item?