How to get value from a reference field and copy it to the another reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2017 03:17 AM
Hi All,
I have a catalog item and have two reference fields, I have to get value from one reference field and copy that value to another reference field. I have tried the below script but it;s not working for me, Please suggest me the correct way here.
I have used Onload client script here...
function onLoad() {
var manager = g_form.getValue('Requesters_Manager');
alert(manager);
g_form.setValue('Resource_Manager',manager);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2017 03:34 AM
Great ! write on change on Requesters_Manager field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
g_form.setValue("Resource_Manager",newValue);
alert("You did it !!!");
//Type appropriate comment here, and begin script below
}
Let me know if this was helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2017 03:43 AM
Hello Divya,
Thank you so much for your help Its working now...
But just small issue here, Here the requester manager value is autopopulated when the page loads and I have set a default value for that to get his manager value like this...
javascript:new getUserValues().getManager();
So when the page loads we can set the requesters manager as it is autopopulated, But here it won't set the resource manager as we have used onchane script here.
Is there any way can we fix this...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2017 03:21 AM
Hi,
You cannot copy a value into a reference field you need to copy a sys_id in a reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2017 03:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2017 03:50 AM
Well in that case a On load script will be useful. Keep in mind the order it executes.
condition should be if(g_form.getValue(fieldname) ! = '')
do the same code for populating the value.
Let me know if this was helpful