- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2014 02:57 PM
Hello All,
This seems so easy on the surface but I have been unable to copy one Reference Field to another ( even the Eureka Actions tab doesnt let you do this when creating a business rule). I have one reference field ( Approval For) that has a value in it. I can pull the value and even display it as message. However I can not populate this value into another reference field ( Change Number) leaving me to have to type it in. Both fields reference the the Change task list, I would love it if someone could show us very simply how to extract from field A and input into field B. I know reference fields rely on things like Display Values and sys_ids. I have tried every combination of methods and tried using getDisplayValue()); to get the original Value and g_form.setValue to as well as scowering the wiki /community . Thank you in Advance, there are many applications for why anyone would need to do this , this is just one of them.
BR - After, on insert or update of approval form
findChange();
function findChange() {
var ri = new GlideRecord("sysapproval_approver");
ri.get('sys_id', current.sysapproval);
//this does display the correct value when I save the form.
gs.addInfoMessage(current.sysapproval.getDisplayValue());
// trying to get an acceptable value for which I can pass into set the destination field , this is unsuccessfull
var change = current.sysapproval.getDisplayValue();
g_form.setValue( 'u_change', change);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2014 06:59 PM
Why do you have 2 fields for same table? Doesn't make sense to me
current.sysapproval.toString() // this will give sys id
current.sysapproval.getDisplayValue() will give.the display value of reference field. Number in this case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2014 08:36 AM
Kalaiaran. Thank you so much. Perhaps others also alluded to this but I didnt understand without the full code. The script is so simple and works. I am not sure why I had such an immense amount of difficulty. I have to do the same thing now on the Change From copy- Opened by into Assigned to - so i will try to use the same principal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2014 07:11 PM
we cant use g_form in BR. Instead we can directly set value as below
current . <field name>=<your value>;
When your field is of reference type we need to give sysid as the value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2014 08:11 AM
Can you expand on that please. instead of G-form what do we do to fetch this sys id from field one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2014 08:13 AM
Run this code
function findChange() {
var ri = new GlideRecord("sysapproval_approver");
ri.get('sys_id', current.sysapproval);
//this does display the correct value when I save the form.
gs.addInfoMessage(current.sysapproval.getDisplayValue());
// trying to get an acceptable value for which I can pass into set the destination field , this is unsuccessfull
var change = current.sysapproval.getDisplayValue();
current.u_change = current.sysapproval;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2014 08:25 AM
Anurag,
i really appreciate your time and help. This did not work, i beileive it has to do with getting the sys_id of the reference field, usually fields can be copied with the method you outlines if they are say string fields. If you want try in your own test instance, copying one reference field to another, replacing my fields with yours, it is proving quite challenging.