- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 02:21 PM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 03:04 PM
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);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 02:38 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 02:39 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 03:04 PM
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 03:15 PM
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?