How to copy string field value to reference field in business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 01:02 AM
Hi all,
I created 'ticket_number' (string filed) - in incident table
I want to copy the 'ticket_number' number to reference field.
I am using BR code like the below
current.instance = current.ticket_number;
it is working but record is not visible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 01:04 AM - edited 11-25-2022 01:06 AM
which table does your reference field refers to? Reference fields accept sys_ids. You need to glide that table with number and pass the sys_id in current.instance.
You can also try:
current.instance = current.getDisplayValue('ticket_number');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 01:05 AM - edited 11-25-2022 01:05 AM
Hi @AnilM99 ,
Your reference field refers to which table ? you need to get reference from table using sys_id.
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 01:09 AM
Hi Anil,
does the reference table has the record that your are trying to copy?
On which table did you write the BR?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 01:11 AM
Hello @AnilM99 ,
You cannot paste a string value into a reference field directly to so so you could need to also glide the table which the field is setting into it
You can use the below code:
var elep = new GlideRecord('referred table name');
elep.addQuery('number',current.ticket_number);
elep.query();
if (elep.next())
{
current.instance=elep;
}
Please mark my response as Correct / Helpful based on Impact.
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.