Pricefx Classic UI is no longer supported. It has been replaced by Pricefx Unity UI.

 

Create Workflow

In Workflow Builder you can create two types of logics:

  • 99592799 – Generates the approval workflow. 
  • 99592799 – Defines a logic that can be called after a particular approval step is executed. 

Workflow Logic

To create a new workflow definition:

  1. Go to Configuration > Workflows > Workflow Logics.
  2. In Category select Workflow Logics.
  3. Click the Add  icon to set up a new workflow.
  4. In the Workflow Type drop-down select for which type of document the workflow should be used.
  5. In the Name drop-down select the same document type. If you intend to use this logic for Quote Types, type a unique name instead (e.g., MyQuoteType).
    (info) If there are more workflows set as Active for a certain document type, you can choose whether the valid logic is picked up based on the document's effective date (and not the submit date). This is set in General Settings in Configuration.
  6. Enter a Label (optional), Valid After date and the Status (Active or Inactive).
  7. Click the View/Edit Details  icon.
  8. Create the workflow logic, i.e. define the condition that will trigger the workflow and assign either approval or watcher step to this condition. 
    You can also: 

    • Assign multiple users / user groups to a single step (using the .withApprovers.withUserGroupApprovers.withUserWatchers or .withUserGroupWatchers methods). 

    • Determine how many distinct users must approve before the step is marked as Approved (using the .withMinApprovalsNeeded(int) method; if this method is not used one distinct user is assumed).

      • If the approval is up to individual users, you need to assign this step to as many users as the minimum number of approvals (or more). 

      • If the approval is up to a user group, you can define only one group (the minimum number of approvals can be achieved within one group).

      • Other notes:

        • The same user cannot approve the document more than once; only the Workflow Admin can.
        • Users can perform multiple approvals on a single document only if they belong to multiple user groups – then they can act as an approver once for each group (regardless whether it is an approval or denial). An admin is allowed to do as many steps as defined in the Min Approvals Needed value in the logic.
        • If the Workflow Admin does the approval, it is not on behalf of a specific user, it is just one of the required approvals (and it does not matter who the other users performing the approval are). The purpose of this functionality is to prevent a workflow from getting stuck if any of the specified users becomes unavailable. It also helps you achieve the functionality of a parallel workflow (without nesting).
    • Configure denial reasons for users to select from.

    • Make it mandatory for approvers to add a comment. Use the method .withMandatoryComments(String... actions) to define, for which action types a comment will be mandatory. Only "APPROVE" and "DENY" actions are accepted.
    • Run a custom logic after a particular step in a workflow is executed. For details see 99592799 below.
    • Define a quick turnaround of the document if it is rejected by an approver.
    • Restrict adding extra approver/watcher steps to Workflow Admins only.
    • Override the element's timeout period (similarly as in calculation logics).

    When creating the logic, you will work especially with the workflow (WorkflowDTO type) and submitter (User type) objects; for more details see the API Documentation.

  9. Click the Save And Close button.

Examples

This example shows how to add an approval step if TotalPriceValue is more than 1000:

def total = api.getElement("TotalPriceValue");
def approvers = ["mary","bob"]
if (total != null && total > 1000) {
  workflow.addApprovalStep("approval").withApprovers(*approvers).setReason("Total Price went over threshold.");
}

If the ApprovalStep is added with no condition, the workflow is always generated for the given document type. 

This example just adds a watcher step. When it is executed, the defined user/group receives an email notification. 

workflow
  .addWatcherStep("Review").withUserGroupWatchers("Managers").setReason("Status update")

Workflow Post Step Logic

With Workflow Post Step Logic it is possible to run a custom logic after a particular step in a workflow was executed. This allows you to use the result of that step in the logic. For example, if an approval is handled by a person not belonging to the sales organisation the deal is for, you can trigger automatic adding of an extra approval step.

This functionality is intended only for modifying the workflow logic (e.g., add approval/watcher steps, implement custom workflow notifications). It is not designed to handle complex logics outside of the workflow scope.

Steps:

  1. Go to Configuration > Workflows > Workflow Logics.
  2. In Category select Workflow Post Step Logics.
  3. Click the Add  icon to set up a new Workflow Post Step Logic. Its uniqueName must be different from the  Workflow Logic name. 
  4. In the logic you can use options available for the 99592799 or calculation logic.
    In addition, you can use here two specific methods (belonging to the currentWorkflow variable) which insert additional steps:
    • .insertApprovalStep(String stepName)
    • .insertWatcherStep(String stepName)
    You can also work with the approvable variable which represents the object for which the workflow is used. (In case of a workflow used for a quote, there is also the specific object quote, for Agreement/Promotion workflow there is the contract object etc. but these specific objects point to the same object as approvable. The approvable object is useful if you want to make your Post Step Logic universal.) 
  5. Save the Workflow Post Step Logic. 
  6. Go back to your workflow logic and use one of the following methods:

    • .withPostStepLogic(String postStepLogicUniqueName)– Runs the given post step logic after the step in which you have used this method. This has a higher priority over the Default Post Approval Step Logic.

    • .withDefaultPostApprovalStepLogic(String postStepLogicUniqueName)– Runs the given post step logic after every approval step in the workflow. 

    (tick) If you specify the Post Step Logic in a step but keep it empty (.withPostStepLogic("")), it disables Post Step Logic for the given step. 

  7. After you save your workflow logic, the presence of the Workflow Post Step Logic is visible in the Workflow window – in the Post Step Logic Name column of the corresponding step.

  8. Once the step is executed (i.e. becomes Approved, Denied or Withdrawn), the custom logic code is run. If the run was successful, the cell becomes green; if it failed, it is red and you can find the error in the log. 

(info) It is also possible to run a Workflow Post Step Logic even when there is no workflow defined or no approval steps are generated. For details see /wiki/spaces/UDEV/pages/4121724604

Examples

This workflow logic defines that after every approval step the Post Step Logic "defaultPostLogic" will be executed – except for the first approval step in which running of a Post Step Logic is disabled. 

workflow
                .withDefaultPostApprovalStepLogic("defaultPostLogic")
       workflow
                .addApprovalStep("DefaultApproval")
                .withApprovers("user1")
                .withPostStepLogic("")
                .setReason("Standard approval")
        workflow
                .addApprovalStep("ExtraApproval")
                .withApprovers("user2")
                .setReason("Additional approval")


This Post Step Logic example shows how to insert another approval step "postAdded" when the step (after which this Post Step Logic was executed) was approved.

if (workflowHistory.activeStep.approved) {
  currentWorkflow.insertApprovalStep("postAdded").withApprovers("user") 
}


This Post Step Logic checks whether the whole workflow got approved or not.

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()}"])
}


This Post Step Logic example shows how to insert a new approval step and disable executing Post Step Logic in the step being inserted. 

currentWorkflow
  .insertApprovalStep("defaultPostAdded")
  .withApprovers("user")
  .withPostStepLogic("")

Found an issue in documentation? Write to us.