...
Configuration
You can set up a Workflow Post Step Logic to run after a particular step in the workflow has been executed (with the result approved/denied/withdrawn). You can use this step’s result in the Post Step logic to make a decision.
Workflow Logic
Workflow logic builds the workflow Steps, and can add the Post Step logic to any of the Steps. It can either add a default Post Step logic, which will be started after execution of each Step or it can add specific Post Step logic to a particular workflow Step.
WorkflowDTO
withDefaultPostApprovalStepLogic(String postStepLogicUniqueName) - Sets the same Post Step logic for all Steps.
ApprovalStepDTO
withPostStepLogic(String postStepLogicUniqueName) - Sets the Post Step logic for an individual Step.
.withPostStepLogic("") - Disables the Post Step logic for an individual Step.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
workflow.withDefaultPostApprovalStepLogic("DefaultPostLogic") // ❶ workflow.addApprovalStep("DefaultApproval") .withApprovers("user1") .withPostStepLogic("") // ❷ .setReason("Standard approval") workflow.addApprovalStep("ExtraApproval") // ❸ .withApprovers("user2") .setReason("Additional approval") |
❶ Default Post Step logic for all Steps.
❷ Disabling the Post Step logic for this specific step.
❸ This step will use the default Post Step logic, because it does not override and does not disable.
Post Step Logic
Is a logic of type Workflow, nature Post Step.
Post Step logic is executed right after the Approval Step has been executed (i.e., approved / denied / withdrawn).
Tip |
---|
The Post Step logic has the right to modify data tables, e.g., you can use methods like api.addOrUpdate() to write various audit logs or statuses to tables (e.g., Company Parameters). |
Special Variables (Bindings) Available in Post Step Logic
workflowHistoryMap (with keys "steps", "activeStep"; each Step has e.g., also the key "stepHistory").Samples:
- workflowHistory.activeStep.approved
- workflowHistory.activeStep.denied
- workflowHistory.activeStep.executedByNames[0]
- workflowHistory?.steps?.collect{it.approved}
currentWorkflow
Is of type InsertWorkflowStepsDTO.Samples:
- currentWorkflow.insertApprovalStep(String stepName)
- currentWorkflow.insertWatcherStep(String stepName)
quote | pricegriditem | rebateagreement | contract | dcr | pricelist | rebaterecord
The document being in the approval process.
approvablePoints to the same as Quote, Agreement/Promotion, etc.Could be useful if you needed a universal Post Step logic, regardless of the document type.
Info |
---|
api.currentItem() - Reference to the same entity as variable approvable. |
Post Step Logic Code Samples
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (workflowHistory.activeStep.approved) { currentWorkflow.insertApprovalStep("postAdded").withApprovers("user") } |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (workflowHistory.steps.findAll{it.approvalStep}.every{it.approved}) { // ❶ api.addOrUpdate("P", [ // ❷ sku: api.uuid(), attribute1: "approved ${approvable.getTypedId()}" ] ) } else { api.addOrUpdate("P", [ sku: api.uuid(), attribute1: "notApprovedYet ${approvable.getTypedId()}" ] ) } |
❶ Check if all Steps have been approved.
❷ Store the information about complete approval of the SKU to the attribute of the Product master table.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
currentWorkflow.insertApprovalStep("defaultPostAdded") // ❶ .withApprovers("user") .withPostStepLogic("") // ❷ |
❶ Inserting new Approval Step.
❷ Disable executing Post Step logic in the step being inserted.
Testing Post Step Logic
Pricefx Studio does not have yet support for Post Step logics, so you must:
Add writing of debugging information to the Log file (e.g.,
api.logInfo()
).Deploy the logic to your partition.
Open the Log (Administration > Logs > Logs) in a separate tab.
Tip In Unity, you can right-click on links/menu items and open in another tab. Submit the document for approval.
Approve/deny/withdraw the Step (which has the Post Step logic assigned).
This will trigger the Post Step logic of the Step.
Check the Log for your messages.
Error Handling
As this logic is running as a background process, it does not have any UI, where you could see its status.
If the logic ends OK (without any exception), its name in the Workflow window is displayed in GREEN color.
If the logic fails with any exception (either unhandled or raised by the logic), its name in the Workflow window will be RED but the process will continue - i.e., the next Approval Step will be executed.
If you need to stop processing of the workflow, it’s not possible but from such Post Step logic you can add a new Step, which should be approved e.g., by Admin.