get sys_id before creating Record Producer

georgechen
Kilo Guru

Hi folks,

Just wondering if it is possible to fetch the sys_id from producer object.   I have read through Producer Object   and it is believed this is not feasible.

Any advice?

Thanks in advance.

George

7 REPLIES 7

Aric5
Mega Expert

Absoloutely maybe?   Depends on the use case.   If you wanted to populate something on the form it wouldn't work, but if you wanted to populate another table with the sys_id you'd be good.



current.sys_id in the "contains tab" in scripts.



HI Aric, in this case it was to populate the the record itself before the submission. it does not seem feasible to achieve so, so my colleague has to achieve the goal with another approach. Thanks for your reply


Nick Parsons
Mega Sage

We can use the RP (render properties) API with the getParameterValue() method to get the sys_id of the current record producer like so. You can use this in the producer's script:

 

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

 

This is the approach recommended by the ServiceNow documentation in the article Populate record producer data and redirect users

 

You can however also use cat_item instead (yes, this works in a record producer), which is what ServiceNow use in some of their OOTB scripts, such as in their HRSD app. This has the advantage of being able to access other properties, such as the name of the record producer (via: cat_item.name):

 

current.u_record_producer = cat_item.sys_id;