add parent record

Sweta24
Tera Contributor

 

I'm using below code to create RITM from scheduled job , it creating RITM , now want to add that RITM as parent for  u_exception_request  record.

or u_exception_request record --> related list --> add this RITM

 

 

var excption = new GlideRecord("u_exception_request");
excption.addEncodedQuery("approval=approved");
excption.query();
excption.setWorkflow(false);
 
while (excption.next()) {
 
    var gdt = new GlideDateTime(excption.u_end_date);
    gdt.addDaysUTC(89);
    var cartId = GlideGuid.generate(null);
    var cart = new Cart(cartId);
    var exp = excption.u_end_date + gdt;
    //add your requested item to the cart by sys_id of the catalog item
    var item = cart.addItem('b6063c0fdb5ad890fc9c115e689619e2');
    cart.setVariable(item, "requested_for", excption.u_requested_for);
//  cart.setValue(item, "parent", excption.task_effective_number);
   
    cart.setVariable(item, "short_description", "Security exception request");
    cart.setVariable(item, "assignment_group", excption.assignment_group);
    cart.setVariable(item, "description", excption.description);
    var rc = cart.placeOrder();
    // gs.log('item-' + rc, "Addrenew");

    // var ritm = new GlideRecord('sc_req_item');
    // if (ritm.get(rc.sys_id)) {
    //     ritm.parent = excption.sys_id;
    //     ritm.update();
    // }
}
1 REPLY 1

Shivalika
Mega Sage

Hi @Sweta24 

 

First create an RITM and then add it as parent. Dont do so much looping in same script and make it complicated. Create an RITM and store the value in some variable. 

 

Then glide over your u_exception_request table , whatever relation is there, as per that add the RITM - that's simple and easy to debug also. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY*