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

When i update sctask state as closed complete it should update RITM and REQ/Universal state too?

Shiva prasad t
Tera Guru

1) when i update the state of sctask to any, then I need to update the state of RITM and REQ and Universal request too?

 2) When I update the work notes or additional comments of sctask it should update on RITM and on Universal request too?

1 ACCEPTED SOLUTION

It's working now like this

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    var closedCompleteCount = 0;
    var closedInCompleteCount = 0;
    var gr = new GlideRecord('sc_task');
    gr.addQuery('request_item', current.request_item); 
    gr.query();
    var totalCount = gr.getRowCount();
    while(gr.next()){
        if(gr.state == 3){
            closedCompleteCount++;
        }
        if(gr.state == 4){
            closedInCompleteCount++;
        }
    }

    var ritm = current.request_item.getRefRecord();
    var req = current.request.getRefRecord();
    if(totalCount == closedCompleteCount){
        ritm.state = 3;
        ritm.update();
        req.state = 3;
        req.update();
    }
    if(closedInCompleteCount > 0){
        ritm.state = 4;
        ritm.update();
        req.state = 4;
        req.update();
    }

})(current, previous);

View solution in original post

22 REPLIES 22

fydyrd
Kilo Contributor

Make sense of your situation, would you say you are attempting to mechanize this or you are finding out if it ought to work that way?

Go ahead and mark right, Assuming I addressed your question. <a href="https://axolotlsquishmallow.com/products/cow-squishmallow">strawberry cow squishmallow</a>
Will be useful for future guests searching for comparable inquiries 🙂

ghdfgdrg
Kilo Contributor

Thanks for sharing such a wonderful inforation here. it help me a lot. Thanks again rosa's breakfast time

gokuzeus67
Giga Contributor

Thanks for sharing such a wonderful information here, it help me a lot. Thanks again Cowsquishmallow