Requested for is populating Empty on Request an Requested Item table

Abhit
Tera Guru

Hi All,

Requested for is populating empty for the RITM Created for the item.

I have the below business rule written on sc_req_item table.

Condition: current.request.requested_for != current.variables.requested_for

(function executeRule(current, previous /*null when async*/ ) {
var grREQ = new GlideRecord('sc_request');
grREQ.get(current.getValue('request'));
grREQ.setValue('requested_for', current.variables.requested_for);
grREQ.update();
gs.log(grREQ, " Requested For");

})(current, previous);

find_real_file.png

 

On RITM and REQ Requested For is empty:

find_real_file.png

if the disable the above business rule, the items which has the requested for variable, in those RITM requested for is empty.

find_real_file.png

find_real_file.png

 

Please help to resolve this issue.

 

Thanks

 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

The Service Portal Order Confirmation Request for field as shown in your first screenshot is different than a variable that you may have on a catalog item named requested_for, so with the way you've written your business rule script, that's why it's overriding the OOTB rule that would set Requested for on the REQ (and RITM, though that's really the REQ shown on the RITM form) and is blank - when the variable doesn't exist.  If you inactivate this rule and the Requested for as shown on the Service Portal Order Confirmation page is populated on the REQ, then that's good news as the OOTB rule is still working.  If you want a Requested for variable to populate the field on the REQ when this variable exists, your sc_req_item business rule script should look like this 

(function executeRule(current, previous /*null when async*/ ) {
if(current.variables.requested_for){
var grREQ = new GlideRecord('sc_request');
grREQ.get(current.getValue('request'));
grREQ.setValue('requested_for', current.variables.requested_for);
grREQ.update();
gs.log(grREQ, " Requested For");

}
})(current, previous);

View solution in original post

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

The Service Portal Order Confirmation Request for field as shown in your first screenshot is different than a variable that you may have on a catalog item named requested_for, so with the way you've written your business rule script, that's why it's overriding the OOTB rule that would set Requested for on the REQ (and RITM, though that's really the REQ shown on the RITM form) and is blank - when the variable doesn't exist.  If you inactivate this rule and the Requested for as shown on the Service Portal Order Confirmation page is populated on the REQ, then that's good news as the OOTB rule is still working.  If you want a Requested for variable to populate the field on the REQ when this variable exists, your sc_req_item business rule script should look like this 

(function executeRule(current, previous /*null when async*/ ) {
if(current.variables.requested_for){
var grREQ = new GlideRecord('sc_request');
grREQ.get(current.getValue('request'));
grREQ.setValue('requested_for', current.variables.requested_for);
grREQ.update();
gs.log(grREQ, " Requested For");

}
})(current, previous);