I have a situation where a document needs multiple approvals before it can move to the next state, however, a person in a certain role can override the need for the additional approvals and move the document to the next state. If a person is not in the elevated role, and additional approvals are needed, the document's state needs to remain in a pending status.
When a person clicks an "approve" button, I need the workflow to decide what to do based on the above criteria.
I understand I can use the .PermitIf() to check whether the user is in a role, and whether there are more approvals needed. What I don't understand is how to keep the status at "pending" if there are additional approvals needed and the user is not in the elevated role.
When I set the Permit() method to keep the status the same, I got an error telling me to use Ignore() or PermitReentry(). When I used Ignore(), I got an error stating that I had multiple permitted exit transitions.
So how to handle something like this? The following doesn't work:
_machine.Configure(State.AgencyPending)
.PermitIf ( Trigger.Approved, State.GOMBPending, ()=> NoMoreApprovals() || IsAgencyHead() )
.Permit ( Trigger.Approved, State.AgencyPending )
.Permit ( Trigger.Denied, State.AgencyDenied );
Nor does this:
_machine.Configure(State.AgencyPending)
.PermitIf ( Trigger.Approved, State.GOMBPending, ()=> NoMoreApprovals() || IsAgencyHead() )
.Ignore ( Trigger.Approved )
.Permit ( Trigger.Denied, State.AgencyDenied );
Thanks