Document Creation Workflow

Document creation workflow is useful if you expect more users to cooperate on creating a document (a Quote, Agreement/Promotion, Rebate Agreement or Compensation), before it is submitted for approval. The co-authors of the document can work on the document each at a time and the document can be moved in the workflow back and forth until it is finished.

To use this feature, follow these steps:

  1. Enable document creation workflow in Administration > Configuration > My WorkflowsEnable creation workflow.

  2. Create a calculation logic (see the guidelines below). The system will always search for and use the most recent, valid and active logic.

  3. Initialize the workflow by clicking the Start CW button in the Quote, Agreement/Promotion, Rebate Agreement or Compensation detail view.
    Forward the document to other users in the workflow using the Back and Next Step buttons.

    • Note that there is no change tracking, so there is no way to see what other users changed.

    • Your pending creation workflows are listed in a panel on the Home page. The CW status (Draft - In Progress - Finished) and label are displayed in the Quote, Agreement/Promotion, Rebate Agreement or Compensation list table and in the header info.

  4. As soon as the work on the document is completed, it can be submitted for approval the usual way. You can also configure automatic submission after the document creation workflow is completed.

Guidelines for Building the Logic

  • To create a workflow logic, go to the Administration > LogicsGeneric Logic menu. The 'Nature' of the logic must be set to Creation Workflow.

  • The logic must contain a creationWorkflow definition with creation workflow steps. The document (Quote, Agreement/Promotion, Rebate Agreement, Compensation) can be referenced in the logic using api.currentItem(). If there are more elements with creation workflow definition, the system will use the first one that returns an instance of the creation workflow.

  • In the workflow step definition, you can assign the step to a user or a user group. Users will receive email notifications (configurable) and they will see a list of their pending creation workflows on the home page. You can also add watchers (users or user groups) – they will be notified by email when a creation workflow step changes.

  • You can allow Document Creation Workflow to automatically finish if it is generated with no steps. (See the last example below.)

  • You can request that Document Creation Workflow moves to a specified step, regardless of what the user clicked in the UI.

  • You can also assign multiple creators to a single workflow step using the methods withUserAssignees and withUserGroupAssignees.

  • You can also set a step label (up to 255 characters) that will be visible to users in the UI.

See also the section Creation Workflow Logic in the Developer Knowledge Base.

Examples

A simple workflow where one user and a user group cooperate on document creation:

def step1 = api.newCreationWorkflowStep() .withLabel("Add Products") .withUserAssignee("Bill.Greene") def step2 = api.newCreationWorkflowStep() .withLabel("Input params") .withUserGroupAssignee("SalesEMEA") return api.newCreationWorkflow() .withSteps(step1, step2)

In the following example, the document is locked for editing for everyone until the creator finishes it and forwards it to the next step. As the workflow is run automatically on every save (set in Configuration), the method withShouldSendNotification prevents sending a notification to the creator on the first save (the document has typedId null before it is saved).

if (!api.isInputGenerationExecution()) { if (api.currentItem("typedId") != null && api.currentItem('creationWorkflowStepLabel') == "Creator step" && api.currentItem('createdBy') != api.user().id) { api.throwException("Only creator can modify the quote in the creator step!") } } def creator = api.currentItem("typedId") != null ? api.find("U", Filter.equal("id", api.currentItem('createdBy')))[0] : api.user() def step1 = api.newCreationWorkflowStep() .withLabel("Creator step") .withUserAssignee(creator.loginName) .withShouldSendNotification(api.currentItem("typedId") != null) def step2 = api.newCreationWorkflowStep() .withLabel("Input params") .withUserGroupAssignee("SalesEMEA") api.newCreationWorkflow() .withSteps(step1, step2)

The following example shows how to let Document Creation Workflow automatically finish if it is generated with no steps and move it to a specified step.

def isCwfType1 = api.currentItem('creationWorkflowStepCount') == 1 def isCwfType2 = api.currentItem('creationWorkflowStepCount') == 2 def cwfType1TriggerCondition = false // some computed value def cwfType2TriggerCondition = true // some computed value if (cwfType2TriggerCondition) { // cwfType2 has precedence over cwf type1 if both conditions are met cwfType1TriggerCondition = false } def theCwf if (/* it should not create cwf at all and finish immediately */ false) { // some computed value theCwf = api.newCreationWorkflow() } else { if (cwfType2TriggerCondition) { def costsStep = api.newCreationWorkflowStep() .withLabel("Costs step") .withUserGroupAssignee("thegroup") def dummyCustomerStep = api.newCreationWorkflowStep() .withLabel("Dummy customer step") .withUserGroupAssignee("thegroup") theCwf = api.newCreationWorkflow() .withSteps(costsStep, dummyCustomerStep) } else if (cwfType1TriggerCondition) { def otherStep = api.newCreationWorkflowStep() .withLabel("Some other step") .withUserGroupAssignee("thegroup") theCwf = api.newCreationWorkflow() .withSteps(otherStep) } // else theCwf remains null, and it won't be finished if ((isCwfType1 && cwfType2TriggerCondition) || (isCwfType2 && cwfType1TriggerCondition)) { theCwf.resetCurrentStepTo(0) } } return theCwf

Found an issue in documentation? Write to us.

 
Pricefx version 12.0