Issue with populating Assigned To field on Incident form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2024 02:29 PM
Need to set Assigned To field in Incident form via REST API/Business rule.
If I use below script,
rec.assigned_to = 'Andrew Och'; // THIS WORKS
but if I use below script,
rec.setValue('assigned_to', 'Andrew Och');// DOES NOT work. Why?
Infact everyone says use sys_id for reference fields. Then why 1st script worked? Why 2nd script failed?
PS - For User table, Diplay is set to FALSE for ALL the fields.
Also in Assigned To dictionary attribute, its all EMPTY.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2024 03:22 PM
Hi, this appears to be a duplicate of this post\thread
Issue with setting the REFERENCE field - ServiceNow Community
As per my comments in your other post sys_id's are used to assign reference data, not display values and I would suspect that the assigned_to field is being set elsewhere\by a different script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 05:26 AM
Hi Tony, No I am only running that script, using scripts-background
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 01:02 PM
Hi Suggy, testing in a PDI background window I see the same behavior as you do, this appears to be as SNC interprets/matches both value and display name when setting values via dot.walk but setValue() only accepts the objects 'value'.
I have never previously dot.walked to display values and would personally avoid this approach unless you can be 100% sure that the display values in your reference data are unique.
var rec = new GlideRecord('incident');
rec.get('979b6060a5954300964fa3aa92874155');
//rec.assigned_to = '5137153cc611227c000bbd1bd8cd2007'; // David Loo
//rec.assigned_to = '46d44a23a9fe19810012d100cca80666'; // Beth Anglin
//rec.assigned_to = 'David Loo';
//rec.assigned_to = 'Beth Anglin';
//rec.setValue('assigned_to', 'Beth Anglin');
//rec.setValue('assigned_to', 'David Loo');
//rec.setValue('assigned_to', '5137153cc611227c000bbd1bd8cd2007'); // David Loo
//rec.setValue('assigned_to', '46d44a23a9fe19810012d100cca80666'); // Beth Anglin
rec.setWorkflow(false);
rec.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 01:20 AM
Hi Tony, I have not dot.walked anywhere 🙂