Populate custom field from sc_cat_item to sc_req_item

Richard Tyler
Tera Expert

I have created a custom reference field on the catalog item table, say u_customfield1, and I want that to be populated on u_customefield2 on the sc_req_item form when a new RITM is created from that catalog item. I do not want to make it a variable as this would require updating over 1000 catalog items.

1 REPLY 1

Harish KM
Kilo Patron
Kilo Patron

Hi @Richard Tyler you can create a after insert BR on RITM table with below script

 

var ritm = new GlideRecord('sc_cat_item');
ritm.addQuery('name',current.cat_item.name); // match catalog name with item name field on ritm table
ritm.query();
if(ritm.next())
{
 
    current.fieldname = ritm.fieldname.toString(); // map the field value on ritm table
    current.update();
}
Regards
Harish