How do you determine who approved or rejected a Flow Designer 'Ask For Approval' action?

terryreints
Tera Contributor
 
2 ACCEPTED SOLUTIONS

Hi @terryreints ,

The sys_id is the record that you put into the step Ask for approval.

TaiVu_0-1697424125829.png

 

Because your case is to update the RITM's comment. So the script should be located also in this step.

TaiVu_1-1697424188778.png

 

We need to replace the part after fd_data from the script to the record sys_id that we get approvals.

Ex: if you're requesting for approval from a Catalog task (37), it will be something like "fd_data._37__create_record.record.sys_id.toString()"

 

/*
**Access Flow/Action data using the fd_data object. Script must return a value. 
**Order number is offset by +1 in Error Handling Section.
**Available options display upon pressing "." after fd_data
**example: var shortDesc = fd_data.trigger.current.short_description;
**return shortDesc;
*/
var recordID = fd_data.<the_step_to_get_record_sys_id>.sys_id.toString(); //Replace your record id in the flow
var grApprover = new GlideRecord('sysapproval_approver');
grApprover.addQuery('document_id', recordID);
grApprover.addQuery('state', 'approved').addOrCondition('state', 'rejected');
grApprover.query();
if(grApprover.next()){
    return grApprover.getValue('approver');
}

 

 

You can also refer to the below docs for more detail about scripting in flow designer.

Inline scripts

 

 

Cheers,

Tai Vu

View solution in original post

Hi @terryreints 

The issue is just related to auto completion/suggestions scripts. If you write the correct syntax it should work anyway.

Let's try the below approach as well. We don't need to wait.

1. Create new Flow Action. Define the Input and Add the Script step

TaiVu_1-1697596466880.png

 

2. Define the Input Variables and put the function into the Script box.

TaiVu_2-1697596568750.png

Also remember to define the output for the function

TaiVu_3-1697596610592.png

 

3. Lastly, define Action Output and drop the Approver output from the function into it.

TaiVu_4-1697596706294.png

 

You can also create your own flow action with configuration only by using Look Up Record  step instead of Script step.

 

Let me know if it works for you

 

Cheers,

Tai Vu

View solution in original post

7 REPLIES 7

Tai,

 

That is very helpful! Thank you.

Unfortunately, we are on Utah Patch 7 and the Flow Designer script editor's fd_data dot walking is broken. I was told by support, "...this issue (PRB1696950) and unfortunately there are no workarounds at this time. The good news is that it is fixed in our next patch for Utah (patch 😎 and Vancouver (patch 3) available after 10/26."

I will upgrade and try your solution soon after that. 

 

Terry

Hi @terryreints 

The issue is just related to auto completion/suggestions scripts. If you write the correct syntax it should work anyway.

Let's try the below approach as well. We don't need to wait.

1. Create new Flow Action. Define the Input and Add the Script step

TaiVu_1-1697596466880.png

 

2. Define the Input Variables and put the function into the Script box.

TaiVu_2-1697596568750.png

Also remember to define the output for the function

TaiVu_3-1697596610592.png

 

3. Lastly, define Action Output and drop the Approver output from the function into it.

TaiVu_4-1697596706294.png

 

You can also create your own flow action with configuration only by using Look Up Record  step instead of Script step.

 

Let me know if it works for you

 

Cheers,

Tai Vu

Tai,

 

Your solution is exactly what I needed.

Thank you so much!

 

Terry