Issue with setting the REFERENCE field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2024 02:36 PM
On INC form, we have a custom field "u_portfolio" referring to Service Portfolio table.
Below is the script where need to set 'Assigned To' and 'Portfolio' fields.
var rec = new GlideRecord("incident");
rec.addEncodedQuery("number=INC0000019");
rec.query();
if(rec.next()){
rec.assigned_to = 'Andrew Och'; // This line WORKS
rec.u_portfolio = 'Collaboration'; //This line FAILS
rec.update();
}
Question - Why setting Assigned to Reference field works but fails for Portfolio reference field?
PS - The dictionary attribute is EMPTY for both the fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2024 03:16 PM
Hi, are you sure it is this script that is setting 'assigned_to '?
As I would expect a reference field value to be set by populating the records sys_id and not it's display value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 05:25 AM
Hi @Tony Chatfield1 Yes, I am running that using scripts - background
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 05:46 AM
Anyone who can help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 07:36 AM
Hello @Suggy,
Can you confirm the 'Collaboration' record is preset in Service portfolio table or not?
If the record present then you have to copy the sys_id of the record and set the field in the script.
var rec = new GlideRecord("incident");
rec.addEncodedQuery("number=INC0000019");
rec.query();
if(rec.next()){
rec.assigned_to = 'Andrew Och';
rec.u_portfolio = 'sys_id of your record'; // As the field is reference type so you have to update with sys_id.
rec.update();
}
Please Mark this answer helpful if it's solves your issue.