I've been updating our approval workflow and I nee...
# general
l
I've been updating our approval workflow and I need to set the next approver as the supervisor of the Employee in the PO but a custom checkbox must be ticked in the supervisor's Employee record. If not ticked, I need to check them the supervisor's supervisor and so on and so forth until I find a supervisor with the box checked. Is this achievable via a workflow (workflow/state field?)? If not, can someone give me an idea about the overall logic I need to make it work via scripts? Thanks in advance.
a
You could probably do it in a workflow but you would need 2 additional states and 2 fields on your PO Field 1 = Supervisor Field 2 = Supervisors Supervisor Not sure your existing states but I imagine ther is a start state with a “submit for approval” button. When someone clicks submit for approval it moves to pending approval state and sets next Approver. Here is where you would insert your 2 new states State 1 = add supervisors supervisor State 2 = update supervisor Put a transition from your start state to “add supervisors supervisor state” using execute on button action Also make sure to set the new supervisor field to employees supervisor upon Exit from your start state In your new state 1 do set field value (on entry). Field = supervisors supervisor; field value equals supervisor (field join) supervisor Condition is IF supervisor custom checkbox = F Then add 2 translations. If supervisor custom checkbox = T then transition to pending approval state If supervisor custom checkbox = F then transition to new state 2 (update supervisor) Then in your new state 2 add a set field value action (on entry). Field = supervisor; field value = supervisors supervisor Add a transition back to your new state 1 (after record submit) Then the workflow should keep transitioning between state 1 and state 2 until it finds the custom checkbox checked
l
@AI1 thank you so much. I'm gonna try it now. It looks like it's gonna work as well if I use a workflow field/state field?
@AI1 I think I did what you said but the WF always evaluates the Supervisor : Budget Holder condition incorrectly. This is why it gets stuck in Add Supervisor's Supervisor state. See screenshots below.
screenshots
Log:
n
I guess you have to create a custom field in which you call supervisor of supervisor on employee record if I am getting it right
a
Can I see the actions you have in each state?
l
@AI1 I think it's captured on the right side of the screenshots above. If you need more details, I can send them. Thanks a lot!
a
Ok 2 changes. In this state add a condition to this action of Supervisors supervisor is NOT empty
Also in this state you need to set the supervisor field to the supervisors.supervisor. So you need to do a join to the supervisor field then get the supervisor from that record
Set the record (join field) to your supervisor WF field Then the field should be supervisor
Actually wait
I take all that back
Are your supervisor and supervisors supervisor fields workflow fields? Or state fields?
l
They are all transaction body fields. @AI1
a
Ok let's try this In initiate state change your set field value action for the supervisor field to be before record submit
Also can you show me the detail of how this is setup? It's cut off here
message has been deleted
In your update supervisor state add another set field value that sets the supervisors supervisor field to NULL But make sure it's the last action in the sequence (maybe even change it to on exit )
Also the transitions in the add supervisors supervisor state that are validating the custom checkbox. Add After record submit as the event for those
l
Here's the action for the Add Supervisor's Supervisor state.
I did try adding the After Record Submit in both transitions but got stuck in Add Supervisor's Supervisor. I tried without After Record Submit. Didn't work too. The setup does make sense to me now but it's just weird that it always evaluates the condition to false.
m
It might work to have a scheduled workflow handle the Supervisor changes. So maybe make a custom checkbox on the transaction called "Supervisor Validation" or something like that. When the PO enters the Add Supervisor's Supervisor state as @AI1 suggested then it checks that Supervisor Validation box Then make a saved search of all PO's with Supervisor Validation = T. Every 30 min the scheduled WF will run and change the supervisor field = Supervisors Supervisor. Then set the Supervisors Supervisor field new again. THen make a new checkbox called "Budget Holder Found" or something> Then if the Supervisor:Budget HOlder = T then mark your budget holder found checkbox on the PO. Then in your original WF set a Transiction to pending approval when the budget holder found = T Maybe??
l
@MGBC thank you. I'm gonna try it.