How to change default Requested for in catalog item

Serhii5
Mega Guru

Hi guys, could you help me, by default, when i try to order from catalog item field "requested for" filling by logged in user, i would like to change it from a variable ?

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Create a before business rule on table sc_request with below details.

Table: sc_request

 

When to run: Before

 

Insert: Checked

 

Advanced > Condition : Empty

 

Script:

 

var grRITM = new GlideRecord('sc_req_item');

 

grRITM.addQuery('request', current.sys_id);

 

grRITM.query();

 

while (grRITM.next()) {

 

  if (!JSUtil.nil(grRITM.variables.requested_for)) {   //assuming requested_for is the name of your catalog variable. Replace this exactly with the name of catalog variable you have.

 

      current.requested_for = grRITM.variables.requested_for; /assuming requested_for is the name of your catalog variable. Replace this exactly with the name of catalog variable you have.

 

  }

View solution in original post

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

I recommend using business rule if this is for all catalog items. Having a run script will require you to modify the workflows for all catalog items. Why modify all workflows when this can be done via a single BR 🙂

- Pradeep Sharma