Issue with setting the REFERENCE field

Suggy
Giga Sage

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.

7 REPLIES 7

Tony Chatfield1
Kilo Patron

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.

Hi @Tony Chatfield1 Yes, I am running that using scripts - background

Suggy
Giga Sage

Anyone who can help?

Appanna M
Tera Guru

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.