Notifications

27 views

Overview


Scheduled Jobs creating multiple Request Items on same Request

Issue


When there are multiple scheduled jobs configured at the same time to generate requests using Service Catalog Script API, Run As is same user for all Scheduled Jobs for the same item, multiple Request Items on same Request might get created. Some Requests doesn't have Request Items.

 

Sample Script in Scheduled Jobs, where these are trying to order same Catalog Item:

var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('e46305bdc0a8010a00645e608031eb0f'); 
cart.setVariable(item,'os','Linux Red Hat');
var rc = cart.placeOrder(); 
gs.addInfoMessage(rc.number);

Run as: System Administrator

Time to Run: 12 AM

Reason


 Since all Scheduled Jobs are ordering same Catalog Item with the same User at the same Time, records in "sc_cart" table might get duplicated or messed up while submitting.

Additional Information


1) Run the scheduled Jobs at different Times.

2) Merge All scheduled Jobs to a single Scheduled Job and place the code in a While Loop to make sure Item Submission follows an order.

Article Information

Last Updated:2019-02-07 04:30:01
Published:2019-02-04