- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2016 08:18 AM
Copy one field to another field in the list
In request i have a field called A and B and also C and D
these A B C D fields are not visisble in the form , only on the list for reporting purpose.
A and B is a reference field
C and D is a String field
Now A and B has already some values for the request i want to copy the same value to C and D
ie A to be copied to C
B to be copied to D
In the above screenshot I want to update the Location B (String) with the same value of Location (reference) and Region B(string) with the same value in Region (reference). I want to update the existing records in the list layout.
I want to update the old records , run a background script to do this. How can we approach
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2016 10:20 AM
Try this script.Check whether the field names are correct or not.
addlocation();
function addlocation() {
var gr = new GlideRecord('sc_request');
gr.query();
while (gr.next()) {
gr.u_location_b = gr.u_location.getDisplayValue();
gr.u_region_b = gr.u_region.getDisplayValue();
gr.update();
}
}
Thanks,
Mihir

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2016 08:27 AM
Hi Venkat,
You can do this by using a client script onSubmit,
Suppose the name of location is loc and that of region is reg.
Now write a script to save the values of them in variables.
var location = g_form.getValue('loc');
var region = g_form.getValue('reg');
Thus you will get the values of location and region, now similarly you can set the value to locA and regB.
g_form.setValue('locA', location);
g_form.setValue('regB', region);
Hope it helps,
Abhinav
Please like, mark helpful or correct as per the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2016 09:08 AM
Hi Venkat,
1.Write a business rule of before insert type that will update the string fields with reference fields.(Use getDisplayValue() function because reference type field stores sys_id value) .
2.For existing records, run background script.
Thanks,
Mihir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2016 09:52 AM
Thanks Mihir
I'm trying for the Old records but couldn't able to do it in background script any help pls
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2016 10:08 AM
Please share the background script you have written.
Thanks,
Mihir