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

Dk nov
Tera Expert

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
Giga 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
4x ServiceNow MVP

View solution in original post

4 REPLIES 4

Voona Rohila
Giga 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
4x ServiceNow MVP

@Voona Rohila - Thank you! It worked!

vermaamit16
Kilo Patron

TryciaK
Tera Contributor

thanks