Copy a reference field value from one table to reference field in another table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2023 11:08 AM
I have a reference field called Requested for in my Accounting table and a reference field called Caller in Incident.
I am using a ui action script to copy values of fields from the Accounting table to Incident. The field that did not copy over was the Requested for field. Both of these reference fields are using the sys_user table. How do I copy the reference field value from Accounting table to reference field value within Incident table so the user that receives this Incident table doesn't have to go add a user after the ticket has been transferred?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2023 12:03 PM
Hi,
It should be fairly simple to copy the values from the old record to the new one.
Something like this should work:
var incGR= new GlideRecord('incident');
incGR.newRecord();
incGR.caller_id = current.requested_for_field_name;
incGR.insert();
action.setRedirectURL(incGR);
Can you share what you have done so far?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 12:27 PM - edited 03-06-2023 03:10 PM
Hello OlaN,
Is this a business rule, ui action, or client script? here is my code for the ui action script.
var cr = new GlideRecord("incident");
cr.initialize();
//copy all the fields needed.
cr.caller_id = current.u_requested_for;
cr.short_description = current.short_description;
cr.insert();
Looks like your script matches pretty closely to what I already have so the only lined I added from your script to my ui action script is incGR.caller_id = current.requested_for_field_name;
Specifically, cr.caller_id = current.u_requested_for;
This is still not copying the reference field value from Accounting ticket to Incident ticket.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 01:07 PM
My example was from a UI script (because that was what you where asking about).
Have you checked the field name on your Accounting ticket table, and verified the name?
Does your current script encounter some error?
Does the logs give some info?
Have you done some debugging attempts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 03:10 PM
Hi OlaN,
The current script did not have any issues, to my knowledge. How should I try to debug this?