Get RecordProducer Name of current RP in RP Script FIeld

Meloper
Kilo Sage

how to Get RecordProducer Name of current RP in RP Script FIeld?

If i use current, this object is related to the created record by the RP

if i use producer, this object is related to the "order" user

 

What do i have to to if i need the name of the RP? Same Question for Business Rules

3 REPLIES 3

Laszlo Balla
Mega Sage
Mega Sage

I'm afraid you'd just have to take the sys_id of the record producer that runs the script an do a GlideRecord, e.g.:

var producerID = ''; // the sys_id of this record producer
var thisRP = new GlideRecord('sc_cat_item');
thisRP.get(producerID);

 

Then you should be able to access any fields of the Record Producer. You can use the same approach in a business rule, i.e. create a GlideRecord class on the catalog item table and get the RP you need.

That's exactly why I wanted to ask.
I find it strange that in this case you can not access "current".
Even with a gliderecord I would have to hardcode the SYSID

Community Alums
Not applicable

Hi,

 

You can hardcode the record producer name in the script

 

current.short_description = 'Your Name of Record Producer'; // you need to hard-code it

 

If you don't want to hardcode it, then use after insert BR on the target table

var gr = new GlideRecord("sc_item_produced_record");
gr.addQuery("task", current.sys_id);
gr.query();
if (gr.next()) {
	current.short_description = gr.producer.name;
	current.update();
}