Flow Designer - Approval - If Manager no Approval required, if Not a Manager then requires Approval.

Mark Lanning
Tera Guru

With In Workflow Editor, we use this If Script below, to check if the Requested For is a manager, if they are then no Approval is Required, If Not a manager will ask for the Requested for Manager to Approve.

 

How can I do the same in Flow Designer?

 

    answer = ifScript();
    function ifScript() {
        var openid = current.opened_by.toString();
        var manid = current.request.requested_for.toString();
        var gr = new GlideRecord('sys_user');
        var grOR = gr.addQuery('manager', openid);
        grOR.addOrCondition('manager', manid);
        gr.query();
        if (gr.hasNext()) {
            return 'yes';
        }
    }
 
 
1 ACCEPTED SOLUTION

Ivan Betev
Mega Sage
Mega Sage

@Mark Lanning ,

 

you are using "Look Up Record" instead of "Look Up RecordS", that is why you don't see the counter.

 

These days, I am trying to achieve modularity without coding first (e.g. by using subflows), however if I really need a fine tuned solution which cannot be made with available components, I do it with custom action(s) 🙂

 

Just make sure to stick to the best practice like naming, modularity, reusability, etc.

 

Regards, Ivan

View solution in original post

8 REPLIES 8

Ivan Betev
Mega Sage
Mega Sage

Hi @Mark Lanning ,

 

I'd user lookup records action to search with conditions from your script and then using if statement to check if any were found => Ask for Approval action else skip further.

 

Regards, Ivan

Mark Lanning
Tera Guru

Thanks for the Tip Ivan.

Still having issues with the Script.

Error: Cannot read property "opened_by" from null,Detail: Cannot read property "opened_by" from null

Ivan Betev
Mega Sage
Mega Sage

Hi @Mark Lanning ,

 

you need to give me more context on what you are doing, then I'll be able to help. Where is this error coming from? Maybe some screenshots.

 

Regards, Ivan

Mark Lanning
Tera Guru

Ivan,

Trying to setup a Flow

Trigger - Service Catalog

I am able to connect the Maintain Item and create the Task, looks good.

My issue is on the Approval.

With the Workflow Editor I was able to use the If Script to check if the Requested For is a manager, then there is no Approval required, but if the Request For is not a manager, then we ask for their Manager Approval.

Then after its approved, I am going to use a Spoke to do some Automation of the Request.

 

I am thinking that the step to Get Information to populate the RITM is not pulling the Opened by information, which is one of the Var on the If Script.