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

Community Alums
Not applicable

HI @terryreints ,

You can find all the records in "sysapproval_approver" table.

Tai Vu
Kilo Patron
Kilo Patron

Hi @terryreints 

You can use the action Look Up to the table "Approvals [sysapproval_approver]" after the Ask for approval action.

 

Or you can try the below script on where you need the information of the Approver.

 

var recordID = fd_data.trigger.current.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');
}

 

 

Let me know if it works for you.

 

Cheers,

Tai Vu

terryreints
Tera Contributor

Tai,

 

What should I use for the sys_id? Is it the sc_task record?

I'm not sure how to script this to get the sys_id. Could you provide a script for that?

My goal is to update the RITM's comment stream in action #44 below to show who processed the approval.

 

Thank you,

Terry

 

terryreints_0-1697211281801.png

 

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