Request and RITM Record

Anubhav24
Mega Sage
Mega Sage

Hi All,

 

When we submit a request from portal , which record gets created first request record or ritm record or the difference is very minuscule , however a lot of BR depend on what gets created first. I am doing one analysis in my instance hence asking this.

At few places I found that request record gets created first and at some places it is mentioned RITM record gets created first.

Can someone please provide guidance on this.

 

Thanks in advance.

 

 

6 REPLIES 6

Nikhil Bajaj9
Giga Sage

Hi @Anubhav24 ,

 

When someone raising a request from Portal the hierarchy will be Request (REQ)-> RITM -> Tasks. So Request will be created first and it will contain RITM (One or more) and every RITM may have one or more tasks.

 

I hope i was able to answer your query. If yes, please mark it - solution accepted.

 

Regards,

Nikhil Bajaj

Please appreciate my efforts, help and support extended to you by clicking on – “Accept as Solution”; button under my answer. It will motivate me to help others as well.
Regards,
Nikhil Bajaj

Ankur Bawiskar
Tera Patron
Tera Patron

@Anubhav24 

Logically speaking REQ gets created 1st, the OOTB workflow on sc_request gets triggered.

Once REQ is approved then RITM is created and then it's associated flow/workflow will kick.

The timestamp could be same for both RITM and REQ creation but RITM will never get created before REQ.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

Although these thread are old but over here it is mentioned that RITM gets created first :

https://www.servicenow.com/community/servicenow-ai-platform-blog/which-came-first-the-request-or-the....

 

https://www.servicenow.com/community/developer-forum/how-ritm-gets-created-once-request-is-submitted...

 

Also if you do a google search the first AI search result returned also states that RITM gets created first and then REQ acts like a wrapper for RITM.

I am not sure because that is a core code and we do not have access to it.

Do you think if I do a simple insert in request table to create a request it may help me to understand ?

 

Thanks

@Anubhav24 

I will suggest to raise a request for your catalog item and see the behavior.

but as per my understanding and knowledge it's REQ and then RITM

You can also try writing a fix script to see and compare

Sample script

(function() {
    var count = 0;
    var grReqItem = new GlideRecord('sc_req_item');
    grReqItem.query();

    while (grReqItem.next()) {
        var reqSysId = grReqItem.request.toString();

        // Get the associated sc_request record
        var grRequest = new GlideRecord('sc_request');
        if (grRequest.get(reqSysId)) {
            var reqItemCreated = new GlideDateTime(grReqItem.sys_created_on);
            var requestCreated = new GlideDateTime(grRequest.sys_created_on);

            // Compare creation dates
            if (reqItemCreated.before(requestCreated)) {
                count++;
                gs.info('REQ ITEM ' + grReqItem.number + ' created before its REQUEST ' + grRequest.number);
            }
        } else {
            gs.warn('Request record not found for sc_req_item: ' + grReqItem.number);
        }
    }

    gs.info('Total sc_req_item records created before their associated sc_request: ' + count);
})();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader