We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

schedule job to create request item

rahul67
Kilo Expert

How to create a request item from schedule job with the Request field of Requested item filled automatically.

4 REPLIES 4

SumanthDosapati
Mega Sage

Hi Rahul,

Use the below script in scheduled job to create an ritm for a catalog item and it will auto set the Request field

var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
 //give sys_id of catalog item
var item = cart.addItem('a1e88857db3132003ec57e7dbf96190f', 1);
cart.setVariable(item,"u_requested_for", gs.getUserId()); 
var rc = cart.placeOrder();

 

Please mark answer correct/helpful based on Impact.

 

Thanks,

Sumanth

can you tell me why 1 is placed in 

var item = cart.addItem('a1e88857db3132003ec57e7dbf96190f', 1);

here?

For creating one request only for the particular record

Requested for is not displaying any value , it is showing as empty.

i have set this according to my names

cart.setVariable(item,"requested_for", gs.getUserID()); 

please help