Producer Object

raprohaska
Kilo Guru

I want to associate data in a user defined table to my record producers and then access that data, via the record producer sys_id, from the record producer script. Is there a way to access the record producer's sys_id from that script so I don't have to hard code it?

8 REPLIES 8

Sathish Kumar M
Giga Contributor

Hi, Please try this code in record producer script.

Please try  var ga= new GlideRecord('user_defined_table');
ga.addQuery('sys_id', producer.reference_fiieldname.sys_id); //reference field is the field from user-defined table mapped or created in the record producer.

 

mark helpful if it fixes the issue.

Brent Sutton
Mega Sage

I believe you should be able to return the record producer sys_id, using Render Properties, with the following code in the record producer's script field:

RP.getParameterValue('sysparm_id')

This technique is described in the ServiceNow docs - Populate record producer data and redirect users.

Let me know if this worked for you.

Brent

P.S. Please mark this as helpful and/or correct if it resolved your question.

Thanks Brent!

This worked for my use case where we have a field on incidents that logs which record producer it was created from—using render properties gave the desired outcome without having to copy and paste the sys_id for each newly created record producer.

A simple, but effective solution!

current.u_record_producer = RP.getParameterValue('sysparm_id');

 

Hey @Tristan Elmore, render properties is a nice feature that doesn't get mentioned very often. Glad this tip helped you. Brent