Can someone tell me when why my dotwalking script isnt working for my order form?

cpinedatx94
Tera Expert

I wrote this script from the help of chatGPT. The goal was to get the value of a field in a reference field by dot walking to it. (The reference field is "u_candidate" and the field i want to grab from inside it is called Clearance[u_clearance_type]). 

 

I then wanted to take the value and set the value of a current field on my current form to it. Here is my script. It does not appear to be working. Any help would be much appreciated.

 

function onLoad() {
   //Type appropriate comment here, and begin script below
   var clearanceType = g_form.getReference('u_candidate').Clearance;
         alert(clearanceType.getValue());
         g_form.setValue('u_req_clearance',clearanceType);  //added semi colon in last
}
2 ACCEPTED SOLUTIONS

@cpinedatx94 Did you see any value in alert? Also, will it be possible for you to share the snapshot of the form?

View solution in original post

The alert is showing a value "Undefined"
 

View solution in original post

5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@cpinedatx94 Try the following.

function onLoad() {
   //Type appropriate comment here, and begin script below
   var clearanceType = g_form.getReference('u_candidate').u_clearance_type; 
    alert(clearanceType);   
    g_form.setValue('u_req_clearance',clearanceType);  //added semi colon in last
}

Does it matter if the fields are choice fields? Both the u_clearance_type and u_required_clearance are both choice fields with the same values

Still not working

@cpinedatx94 Did you see any value in alert? Also, will it be possible for you to share the snapshot of the form?