The CreatorCon Call for Content is officially open! Get started here.

How to make empty variables show up on an sctask that is triggered from an INC

Jennifer Red
Tera Expert

I have a trigger set where if an INC has certain values it will create a REQ, RITM & SCTASK. What I'm having trouble with is that when I try to use the variables I defined in the "catalog" and make them show on the SCTASK it doesn't show anything on the Variables tab. I'm assuming this is because I'm creating the REQ,  RITM & SCTASK myself and not utilizing the Service Catalog as the trigger. Anybody have any idea on how I could require multiple variables on a newly created SCTASK without creating the fields on the sc_task table?

1 REPLY 1

Voona Rohila
Mega Patron
Mega Patron

Hi @Jennifer Red 

Can you please share the code on how you are raising the catalog item?

Below is the Syntax : This will raise catalog item from backend and attach the appropriate flow linked to the item and create REQ,RITM and CTASKS as defined.

////map proper sysid's
var cart = new Cart("newCart", "user_sysid");
var item= cart.addItem('give_item_sysid');
cart.setVariable(item,'variable_name1','value123');
cart.setVariable(item,'variable_name2','value123');
cart.cart.requested_for ='6816f79cc0a8016401c5a33be04be441'; //map the requested for details
cart.cart.update();
var req_id = cart.placeOrder();
gs.info(req_id.number);

or Refer below links

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_referenc...

 

https://www.servicenow.com/community/united-kingdom-snug/example-of-how-cart-api-could-cause-request...

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP