The CreatorCon Call for Content is officially open! Get started here.

How to copy string field value to reference field in business rule

AnilM99
Tera Expert

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 

5 REPLIES 5

RaghavSh
Kilo Patron

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');


Raghav
MVP 2023
LinkedIn

Gunjan Kiratkar
Kilo Patron
Kilo Patron

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

devika relangi
Tera Contributor

Hi Anil, 

 

does the reference table has the record that your are trying to copy?

On which table did you write the BR?

Nayan  Dhamane
Kilo Sage

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

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.