How to make record producer populate field ?

____39
Tera Contributor

I have a record producer variable 'assign to' which mapping to incident table 'assign to' , I want to make this variable automatically populate 'assign to' variable when user request in service portal, How to do it?

1 ACCEPTED SOLUTION

Hi,

If my reply above was Helpful, please mark it as such.

In the record producer script (on the record producer settings page), you can simply use something like:

if (producer.assigned_to == '') {
current.assigned_to = 'sys_id_here'; //you can also set a sys_id to a system property and instead use: gs.getProperty('property_name');
}

This will evaluate if the assigned_to field is empty on your record producer and if so, place a value on the resulting record automatically.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

It's not recommended to hard-code sys_id.

So please create a system property to hold the default user sysId and in record producer script check if value is present in variable or not

If it's nil then set the default user

if(producer.assigned_to.nil())
	current.setValue('assigned_to', gs.getProperty('property_name'));
else
	current.setValue('assigned_to', producer.assigned_to);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader