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

Auto Close RITM

Sharath807
Tera Contributor

Hello, I have requirement in which is an RITM is created for a catalog item without records in particular tab in related list then that RITM state should be auto changed to 'Closed cancelled'.. Is there any way to achieve this .Thanks in advance any help is appreciated.

Screenshot (26).png

1 ACCEPTED SOLUTION

SN_Learn
Kilo Patron
Kilo Patron

Hi @Sharath807 ,

 

You can try the below in after insert business rule:

var ritmRec = new GlideRecord('sc_req_item');
if (ritmRec.get(current.sys_id)) {
    var checkReList = new GlideRecord('sc_task'); //Change with your table
    checkReList.addQuery('request_item', ritmRec.sys_id); //update the field name here as per your table
	checkReList.query();
	if(!checkReList.next()){
		ritmRec.setValue('stage', 'Request Cancelled');
		ritmRec.setValue('state', 4);
		ritmRec.update();
	}
}

 

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

12 REPLIES 12

@Sharath807 ,

I have tested in PDI, please check the below:

 

SN_Learn_0-1722763723025.png

 

Request:

SN_Learn_1-1722763755920.png

 

Running the below in background script(RITM sysID is passed for reference):

var ritmRec = new GlideRecord('sc_req_item');
//RITM sysID
if (ritmRec.get('9f2965fc837fc210e1c15d10feaad38a')) {
    var checkReList = new GlideRecord('sc_task'); //Change with your table
    checkReList.addQuery('request_item', ritmRec.sys_id); //update the field name here as per your table
    checkReList.query();
    if (!checkReList.next()) {
        ritmRec.setValue('stage', 'Request Cancelled');
        ritmRec.setValue('state', 4);
        ritmRec.update();

        var reqUpdate = new GlideRecord('sc_request');
        if (reqUpdate.get(ritmRec.request)) {
            reqUpdate.setValue('approval', 'rejected'); //Set as per your requirement
            reqUpdate.update();
        }
    }
}

 

Result:

SN_Learn_2-1722763859549.png

SN_Learn_3-1722763871638.png

 

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Sharath807
Tera Contributor

@SN_Learn  Its actually 'After'  'insert' business rule.  Is that a problem?

Hi @Sharath807 ,

 

Please try with before insert + update.

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.