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.

Copy value of variable into variable set to another variable on catalog item

Nico12
Mega Sage

Hi,

We have a catalog item where we have a variable set that contain an email field that auto populate with the email of beneficiary.

We also have another hidden field on the catalog item (not on the variable set) where i need to copy that email value.


Someone could help me with this ?

1 ACCEPTED SOLUTION

Hi Sonali,

The email1 field populate automatically on load form cause the beneficiary is the loggedin user before any change is made.

 

But nevermind, i found a way to achieve it.

 

in my onChange script, i made this change  and selected the email1 field as the variable name :

g_form.setValue('email_beneficiary',newValue);

 

Regards,

View solution in original post

4 REPLIES 4

Uncle Rob
Kilo Patron

What have you tried?

Nico12
Mega Sage

I have tried a on change catalog client script on the beneficiary field, so when the beneficiary change, the email should change too and i should get the new value in my email field.

 

My first step is to returned the email field that contains the email but nothing is returned in my log :

 

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}
	var email1 = g_form.getValue('email');
	var email2 = g_form.getValue('email_beneficiary');
	console.log("Email1 = " + email1 + " - Email2 = " + email2);

	//Type appropriate comment here, and begin script below

}

 

email1 return nothing but it should return the email of the beneficiary (the field is not empty, there is an email adress filled in).

 

email2 is the field where i want to copy the value of email1

 

 find_real_file.png

 

Regards

Is your email field populating once you change the beneficiary ? I mean is it autopopulating?

Hi Sonali,

The email1 field populate automatically on load form cause the beneficiary is the loggedin user before any change is made.

 

But nevermind, i found a way to achieve it.

 

in my onChange script, i made this change  and selected the email1 field as the variable name :

g_form.setValue('email_beneficiary',newValue);

 

Regards,