Trigger catalog item

Sneha39
Mega Guru

Catalog Item name : TestItem.

Table :  customvalue( Column name : choice field "Cater" (choices: new,old)

I want to trigger  TestItem when user insert choice "new" on field "cater" 

 

Thanks

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

You would want to create an after insert business rule on the customvalue table for "insert" when the choice for "Cater" field is "New". This can trigger the Cart API, which you'd script in the "advanced" section of this business rule, and you'd use that to order the catalog item: TestItem.

Example: https://community.servicenow.com/community?id=community_question&sys_id=892a0f69db5cdbc01dcaf3231f96...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

5 REPLIES 5

Allen Andreas
Administrator
Administrator

Hi,

You would want to create an after insert business rule on the customvalue table for "insert" when the choice for "Cater" field is "New". This can trigger the Cart API, which you'd script in the "advanced" section of this business rule, and you'd use that to order the catalog item: TestItem.

Example: https://community.servicenow.com/community?id=community_question&sys_id=892a0f69db5cdbc01dcaf3231f96...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hello,

It appears you're only responding to certain individuals, so I'll just mention one last time, that I've given instructions above...as well as a link to an example to do what you're asking.

Thanks


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Ct111
Tera Sage

Hello,

 

This is the code you can use for creating ritm on insert or update of record.

 

var itemGr = new GlideRecord("sc_req_item");
itemGr.initialize();
itemGr.cat_item = 'sys_id of catalog item';
itemGr.request = 'sys_id of parent request';
itemGr.state = 1;
var reqItem = itemGr.insert();

var optionGr = new GlideRecord('sc_item_option');
optionGr.initialize();
optionGr.item_option_new = 'sys_id of catalog item variable';
optionGr.value = 'variable value';
var itemID = optionGr.insert();

var relGr = new GlideRecord('sc_item_option_mtom');
relGr.initialize();
relGr.request_item = reqItem;
relGr.sc_item_option = itemID;
relGr.insert();

var startWF = new GlideRecord('sc_req_item');
if(startWF.get(reqItem)){
startWF.setForceUpdate(true);
startWF.update();
}

 

Mark my ANSWER as CORRECT and HELPFUL if it helps.

I have to trigger the catalog through BR, once that is triggered it will trigger the wf which will create the RITM.

SO please help me with the BR code to trigger the Catalog item.