set string variable when another reference variable has a value

Andre8
Giga Guru

I am trying to set a string field whenever another field, which is a reference field, has a value.

When hand reciept holder 3 has a value, I would like to copy that value to hand receipt holder 1 which is a string field

Andre8_0-1668517689418.png

This sets the reference field:

Andre8_1-1668517779491.png

My attempt at pushing the value to the string field:

Andre8_2-1668517818959.png

 

4 REPLIES 4

Sebastian L
Mega Sage

Change it to run on-change on the variable "hrh_ref" , and use g_form.getDisplayValue('hrh_ref'); to retrieve the displayvalue and save it to your string field


Best regards,
Sebastian Laursen

It needs to check the field when the value of the "In DPAS" field changes to No...then it should check the value of hand receipt holder 3 and populate that value to hand receipt holder 1

Then do it in the other client script so you do it at the same time 🙂


Best regards,
Sebastian Laursen

Mohith Devatte
Tera Sage
Tera Sage

hello @Andre8 i think the on change variable that you are using is wrong .Use hand receipt holder3 in on change variable field in your script and then try it .

You might get the sys_id of the user in string field as hand receipt holder3 is reference so while setting it use get reference and then set it like below

var usr = g_form.getReference('hrh_ref', doAlert); // doAlert is our callback function } 
function doAlert(usr) { //reference is passed into callback as first arguments
g_form.setValue('your_string_field_name',usr.name);
}

Hope this helps 

mark the answer correct if this helps you 

Thanks