How to create a request(RITM) through code in an Order Guide in servicenow

sushma123vu
Tera Contributor

HI,

I have a requirement where I need to create a Request(RITM) in an Order guide through code. So, I am implementing this code In a BR as per my requirement.

Order Guide Name-Tech support

Catalog items in an tech support Order guide are 1)Application support 2)Cost support

So now in order to create a request  in order guide I need to fill these below fields 

1)Requested for(variable in Order guide "Tech support")

2)Category(variable in Order guide "Tech support")

3)Application(variable in catalog item "Application support")

4)Description(variable in catalog item "Application support").

 

So, I need a sample script where I can set values for all the above variables navigating through order guide and catalog items.

5 REPLIES 5

G Ponsekar
Giga Guru

Hi @sushma123vu ,

 

To submit request via script, you need to use CartJS API

Please find doc for reference: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/...

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

Thanks, GP

HarshitaN
Tera Contributor

Hello @sushma123vu 
You can refer to this article:- Order a Order Guide using script - ServiceNow Community

If this helps you, kindly mark my answer as helpful.

Sarthak Kashyap
Kilo Sage

Hi @sushma123vu ,

 

Please check below code

 

var orderGuideAPI = new sn_sc.OrderGuide();
var orderGuide = orderGuideAPI.getOrderBySysID("sys_id_of_your_order_guide");

var items = [
    {
        itemSysID: "sys_id_of_catalog_item_1",
        quantity: 1,
        variables: {
            variable_name_1: "value_1",
            variable_name_2: "value_2"
        }
    }
];
    var item = items
    orderGuide.addItem(item.itemSysID, item.quantity, item.variables);

var request = orderGuide.submit();
gs.info("Order Guide submitted. Request number: " + request.number);

 

Please mark my answer correct and helpful if this works for you 

Thanks and Regards,

Sarthak

HI @Sarthak Kashyap , 

can you also help me with the code of how to set values to order guide variables as it was not mentioned in the above code. Thanks!