Update RITM worknotes based on the variables

Manish2
Mega Expert

Hello All,

I have created one catalog item and defined couple of variables now requirement is once inbound email is received then it will check the two variable's values and if match is found then it will update the work note of RITM.

I am using below code on background script but somehow addcondition query is not in correct syntax due to this its randomly updating the worknotes and not checking the condition.

Please suggest.

var checkmgr = new GlideRecord('sc_item_option_mtom');
var or = checkmgr.addQuery('sc_item_option.item_option_new.name', 'node_name').addCondtion('sc_item_option.value', 'ABC');
or.addQuery('sc_item_option.item_option_new.name', 'subcategory1').addCondtion('sc_item_option.value', 'Test');
checkmgr.orderBy("sc_item_option.order");
checkmgr.query();
if (checkmgr.next())
{
gs.log("Hello");
var chekRITM = new GlideRecord('sc_req_item');
chekRITM.addActiveQuery();
chekRITM.addQuery('sys_id', checkmgr.request_item);
chekRITM.query();
if (chekRITM.next())
{
chekRITM.work_notes = 'solution';
chekRITM.update();
gs.print("number"+chekRITM.number);
}
}

 

Thanks,

Manish

 

 

1 ACCEPTED SOLUTION

Brian Lancaster
Tera Sage

It might be easier to do this in an after insert business rule that has a condition to only run for the one catalog item.  Then in the code you would have access to current.variables like in the workflow.  You could also do this in a run script at the beginning of the workflow that way you can just check the variables without having to look at them thought sc_item_option.

View solution in original post

1 REPLY 1

Brian Lancaster
Tera Sage

It might be easier to do this in an after insert business rule that has a condition to only run for the one catalog item.  Then in the code you would have access to current.variables like in the workflow.  You could also do this in a run script at the beginning of the workflow that way you can just check the variables without having to look at them thought sc_item_option.