How to set the Approval status of RITM to Approved if there is no approval flow for the forms?

raj99918
Tera Contributor

Hi 

 

How to set the Approval status of RITM to Approved if there is no approval flow for the forms right now this approval status is setting to Requested even though that flow dont have approval flow how can I set this one via Business rule?

 

Thanks.

7 REPLIES 7

Runjay Patel
Giga Sage

Hi @raj99918 ,

 

System will put "Request Approval" if there is no flow/workflow attached to item. I would suggest you to create one generic flow to approve the ritm/req and attach that in your catalog if no workflow there.

RunjayPatel_0-1734006206344.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

Hi @Runjay Patel  Thanks for the reply Can you please guide me how Can I achieve this one from Business rule if there is no approval flow then the Approval status should set to Approved this is my requirement.

 

Thanks.

Hi @raj99918 ,

 

There is OOB workflow (Service Catalog Request) which will get attached to request if no workflow/flow attached to it.

 

  1. Deactivate this workflow so that it wont attach to request.
  2. Create one after BR and use below script.
var requestSysId = '3c22299d83661210a9589780deaad3b1'; // Replace with your Request sys_id

var flowContextGR = new GlideRecord('sys_flow_context');
flowContextGR.addQuery('source_record', requestSysId); // Attachments to this Request record
flowContextGR.addQuery('source_table', 'sc_request'); // Table name
flowContextGR.query();

if (flowContextGR.next()) {
    var flowSysId = flowContextGR.flow; // sys_id of the Flow definition
    var flowName = '';

    // Query sys_flow to get the flow name
    var flowGR = new GlideRecord('sys_hub_flow');
    if (flowGR.get(flowSysId)) {
        flowName = flowGR.name; // Flow Name
        gs.print('Flow Name attached to this record: ' + flowName);
    }

    if (flowName == 'Application Intake Request Flow') {
        var gr = new GlideRecord('sc_request');
        gr.get(requestSysId);
        gr.approval = 'approved';
        gr.update();


        var gr2 = new GlideRecord('sc_req_item');
        gr2.addQuery('request', requestSysId);
        gr2.query();
        if (gr2.next()) {
            gr2.stage = 'complete';

            gr2.update();
        }

    }
}

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------