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);



    }  
}

 

1 ACCEPTED SOLUTION

Please check the backend field name of your field 'account expires' from reference table configuration.

I believe it is u_account_expired.

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

14 REPLIES 14

Name in your script and configuration is different.

Please use correct field name in script.

Other part looks good.

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

asd22
Tera Contributor

Thank you, it works with everything for 1 variable set. But its still not getting the date for when the account expires for some reason. This is 100% me doing something wrong, im really thankfull for your assistance so far.

Please check the backend field name of your field 'account expires' from reference table configuration.

I believe it is u_account_expired.

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

asd22
Tera Contributor

In our system its u_account_expires. Im looking for other small mistakes i have maybe done to see if thats the issue.

 

In the main form do i also need a secon script with this:

 

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



    }  
}
 
or should one main script do the job?

asd22
Tera Contributor

Hello, error from my side. Everything works now just fine. I cant thank you enough for this.

 

Regards