The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Triggering using Cart API

HussainM
Tera Contributor

I want to trigger a catalog item using another catalog item and getting input variable from one catalog item to the other, using Cart catalog API by using a custom flow designer action.
If any other ways to do this, please do tell me.
I am relatively new to SN platform. So please do explain in a way fresher can understand.

2 REPLIES 2

Neeraj Modi
Tera Guru

Hi @HussainM ,

 

  1. Create a custom flow designer action that triggers the second catalog item.
  2. In the custom flow designer action, use the Cart API to add the first catalog item to the cart.
  3. In the custom flow designer action, retrieve the input variable from the first catalog item and pass it as a parameter to the second catalog item.
  4. Add the custom flow designer action to the first catalog item's flow.

Example of code snippet:

// Add first catalog item to the cart
var cartAPI = new Cart();
var cartItem = cartAPI.addItem('cat_item_sys_id_1');

// Retrieve input variable from the first catalog item
var inputVariable = cartItem.getVariable('input_variable_name');

// Add input variable as a parameter to the second catalog item
cartAPI.addItem('cat_item_sys_id_2', inputVariable);

// Submit the cart
cartAPI.submit();

 

Please note that you need to replace the 'cat_item_sys_id_1' and 'cat_item_sys_id_2' with the actual sys_id of the catalog items, and 'input_variable_name' with the name of the input variable you want to pass to the second catalog item. Also make sure that you have the right permissions to access the catalog item and cart API.

 

Please mark the suggestion as helpful, if you find it useful to you or others who wants to refer similar content.
Please mark the solution as correct, if the answer provided by me has resolved your query.


Thank you!

Ankur Bawiskar
Tera Patron
Tera Patron

@HussainM 

in flow designer there is an action for this OOB and you need not use any script

Submit Catalog Item Request action 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader