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

How can I create a request & Request Item from Business rule?

Dk nov
Tera Contributor

Hello,

 

Requirement - When any incident get creates with particular value in it, create a request, request item and sc Task.

 

How do I create a business rule on Incident table which creates a request by filling out variables through script and request item. Can you please provide a correct sample script?

 

Thanks in advanced. 

1 ACCEPTED SOLUTION

Voona Rohila
Mega Patron
Mega Patron

Hi @Dk nov 

Yes you can raise catalog item from script.

Below is the sample code:

 

var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item= cart.addItem('give_item_sysid'); //pass catalog item sys_id here
cart.setVariable(item,'variable_name1','value123'); //pass variable name and values
cart.setVariable(item,'variable_name1','value123');
var req_id = cart.placeOrder();

 

Use above code in your BR accordingly and pass values dynamically.


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

View solution in original post

4 REPLIES 4

Voona Rohila
Mega Patron
Mega Patron

Hi @Dk nov 

Yes you can raise catalog item from script.

Below is the sample code:

 

var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item= cart.addItem('give_item_sysid'); //pass catalog item sys_id here
cart.setVariable(item,'variable_name1','value123'); //pass variable name and values
cart.setVariable(item,'variable_name1','value123');
var req_id = cart.placeOrder();

 

Use above code in your BR accordingly and pass values dynamically.


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

@Voona Rohila - Thank you! It worked!

Amit Verma
Kilo Patron
Kilo Patron

Hi @Dk nov 

 

You can use CartAPI. Refer below links and give it a try -

https://www.servicenow.com/community/developer-forum/create-request-from-business-rule/m-p/1513026

https://docs.servicenow.com/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/Cart...

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

TryciaK
Tera Contributor

thanks