Is there a way to get the value in a dot-walked field and populate another field with that same value?

Steve H2
Kilo Expert

There is a lookup field on a form named assigned_to. When it is populated from the sys_user table (by selecting a name from the lookup list) other fields related to the assigned_to are populated (like assigned_to.employee_number, and assigned_to.street). I want to take the value displayed in the assigned_to.employee_number field and populate another field with that value as well.

Is there some way to code that - copy/get the value displayed in a dot-walked field and put it into another field?

I'd rather not have to create client scripts and script includes to go to the user table, get the record and bring back the values already on the screen, then put them in the other field. But if that is the only way to do it, I just need to know that.

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

If this is a catalog item, you will have to create onchange client script on the lookup variable and plug this code in there

 

var usr= new GlideRecord("sys_user");

usr.addQuery("sys_id",g_form.getValue("variable name goes here"));

usr.query(callBack);

function callBack(usr){

if(usr.next()){

g_form.setValue("variable name goes here",usr.employee_number);

}

}

View solution in original post

8 REPLIES 8

sachin_namjoshi
Kilo Patron
Kilo Patron

You can configure business rule on your table to copy data from your reference field to another field.

You can dot walk in business rule for reference field.

Please check example below

 

var req_for = ritm.u_requested_item.u_requested_for.getDisplayValue()

 

Regards,

Sachin

SanjivMeher
Kilo Patron
Kilo Patron

You can use a onBefore Insert/Update business rule to do it.

 

Condition: Assigned To!=NULL

 

current.my_field = current.assigned_to.employee_number;


Please mark this response as correct or helpful if it assisted you with your question.

Abhinay Erra
Giga Sage

If this is a catalog item, you will have to create onchange client script on the lookup variable and plug this code in there

 

var usr= new GlideRecord("sys_user");

usr.addQuery("sys_id",g_form.getValue("variable name goes here"));

usr.query(callBack);

function callBack(usr){

if(usr.next()){

g_form.setValue("variable name goes here",usr.employee_number);

}

}

Steve H2
Kilo Expert

What I was hoping to do was to create an onLoad client script that just copied the values from the .walked fields on the form to other target fields on the form, and not have to go back to the server to get the values since they are already in the form fields. Is that possible?