Workflows
A workflow is a document process modeled as a progression of stages and activities associated to those stages.
Workflows are defined by creating Workflow, Workflow Stage, Workflow Stage Activity, Workflow Stage Transition, and Workflow Activity Capacity custom metadata type records. When a workflow becomes active, a series of workflow-related custom objects (i.e. Workflow Instance, Workflow Instance Stage, and Workflow Instance Document) are instantiated to track the instance of the workflow.
A Workflow Instance has a status (Pending
, Complete
, Canceled
) and an outcome (Approved
, Rejected
, Completed
). As the Workflow Instance transitions between stages, it can optionally assign activities and modify the status of the document associated to it. For example, a workflow can be configured to change the status of a document to In Review
when the workflow starts.
Workflow Stage Activities include tasks, which are to-do items assigned to users to progress a document through a workflow.
Configuration
Workflows are configured using custom metadata types. The custom metadata types that configure workflows include:
Workflow - a document process.
Workflow Stage - a possible step in a workflow.
Workflow Stage Activity - the type of activity or to-do item that upon completion and when paired with transitions activate different stages in a workflow.
Workflow Stage Transition - the criteria that must be met to move to a different stage in a workflow.
Workflow Activity Capacity - the capacity in which a user acts when reviewing an activity.
Workflows and Workflow Stages are associated by a one-to-many relationship. Each Workflow Stage can have multiple activities associated. Workflow Stage Transitions facilitate the transition of workflows between stages.
Workflows
A workflow or document process is defined in the CM_Workflow__mdt
custom metadata type. Each workflow is associated with a single lifecycle and has entry criteria that determine whether/when a document can enter the workflow. Only a single document is supported per workflow.
Key concepts
Workflows are associated with a lifecycle.
For a document to enter a workflow, it must match the entry criteria configured for the workflow. Entry criteria is stored on the workflow’s
CM_Entry_Criteria__c
field. Visit Criteria definition.A single document is supported per workflow.
Auto-start workflows automatically start when a document is created. Visit Auto-start workflows.
Localization
The name of the workflow is translated in the user interface using the custom label referenced in the workflow’s CM_Custom_Label_API_Name__c
field.
Auto-start workflows
To configure a workflow to start automatically when a document is created set the value of its CM_Auto_Start__c
to true
.
Note
Be careful when configuring auto-start workflows. If multiple auto-start workflows are found for a document, the document enters an error state and requires manual intervention.
Workflow Stages
Workflow Stages are defined in the CM_Workflow_Stage__mdt
custom metadata type and represent the list of possible steps in a workflow. Not every instance of a workflow will necessarily enter every defined Workflow Stage. The stages that become activated in a workflow instance depend on the outcome of workflow activities and the transitions configured for the workflow. For a list of workflow stage fields, visit Workflow Stage.
Key concepts
Workflow Stages represent the list of possible steps in a workflow.
Workflows should have a single initial stage that represents the first step in the workflow.
Manual stages require user intervention to assign activities.
Workflow stages can (optionally) update document state. Visit Document State.
Workflows can have multiple final stages. When the workflow reaches one of these stages, it is considered complete.
Document State
To update the state of the document when the workflow enters the stage, populate the CM_Document_State__c
field on CM_Workflow_Stage__mdt
with the desired state. If null, the workflow will not update the document state when the workflow enters this stage. For a list of document state fields, visit Document State.
Note
The value of CM_Document_State__c
must be a valid state for the lifecycle associated to the workflow.
Localization
The name of the Workflow Stage is translated in the user interface using the custom label referenced in the Workflow Stage’s CM_Custom_Label_API_Name__c
field.
Workflow Stage Activities
Workflow Stage Activities are the types of activities or to-do items that upon completion and when paired with transitions activate different stages in a workflow and progress a document through the workflow. Workflow Stage Activities are defined in the CM_Workflow_Stage_Activity__mdt
custom metadata type. You can associate many Workflow Stage Activities to a single Workflow Stage. For a list of Workflow Stage Activity fields, visit Workflow Stage Activity.
Key concepts
Activity assignment can either be manual or automatic. Visit Assignment.
Activities are either general (e.g. peer review) or approval (e.g. MLR review) activities. Visit Type.
When the
Require Electronic Signatures
field on theMCM Global Setting
custom metadata type is activated, all workflow activities require an electronic signature. Visit Electronic signature.
Assignment
The assignment of activities is configured using the CM_Assignment__c
field. To prompt a user to manually assign activities, set the value to Manual
or Document Role
, otherwise the activity is assigned to the Document Creator, Document Owner, Workflow Creator, or Workflow Owner.
If the activity is assigned to a Document Role
, the activity is pre-populated with all users with that specified Document Role. Users can be added or removed from the pre-populated list before starting the workflow.
Note
Activities cannot be assigned to inactive users.
When the CM_Role_Assignment__c
field is populated, the activity that is created as part of the workflow will create a specified Document Role for the owner of the activity. When the CM_Role_Assignment__c
field is not populated, the Reviewer or Approver role is automatically assigned depending on whether the activity is configured as an Approval or General activity.
Note
The Owner role cannot be selected in the Role Assignment field as a document is allowed to have only one Owner role.
When an activity is configured as optional, the Start Workflow modal displays a toggle button next to the activity. The user can use this toggle to specify whether to create an assignment for that activity or not. At least one activity must be assigned before the workflow can be started.
Due date
The due date is configured with both the Days to Complete (mvn__CM_Days_To_Complete__c
) field and the Days to Complete Calculation (mvn__CM_Days_To_Complete_Calculation__c
) field. The former sets the default number of days that a collaborator has to complete the activity while the latter determines whether the number of days is calculated with actual days or with business days.
The default value of the Days to Complete Calculation field is Actual Days
. This means that if multiple collaborators are assigned the same activity, then the due date for all of the collaborators is the same, even if they are in different timezones and have different business hours. However, if the Days to Complete Calculation field is changed to Business Days
and multiple collaborators are assigned the same activity, then the due date for the collaborators may vary based on their timezones as well as any Business Hours records that are set for those timezones.
Actual days | Business days | |
---|---|---|
Due Date field | Business days until due field | Due Date field |
To take into account of collaborators' timezones, holidays, and business hours when assigning a workflow stage activity and due date:
Set the collaborators' timezones. Reference Salesforce's documentation on how to Change default time zones for Users and the organization.
Create corresponding Business Hours records for each of the collaborators' timezones. Reference Salesforce's documentation on how to Set Business Hours.
Note
Out of the box, Salesforce offers the Default Business Hours record while Komodo Publications Planning ships with the PP_Default Business Hours record. The PP_Default record contains the major U.S. holidays. Customers should clone the PP_Default record and modify the clone as necessary as well as create any additional Business Hours records for other regions and timezones as appropriate. If no Business Hours record is created for a collaborator's timezone, then the PP_Default record is used. If multiple Business Hours records are created for a collaborator's timezone, then the record that was created first is used.
On the desired Workflow Stage Activity (
mvn__CM_Workflow_Stage_Activity__mdt
) metadata record:Set the Days to Complete field to equal the number of business days the collaborators have to complete the activity.
Set the Days to Complete Calculation field to
Business Days
. This will prompt the Business days until due field to appear in the Start Workflow modal.
Once the regional business hours are set up for a workflow stage activity and a publication coordinator assigns the activity to multiple collaborators, the Business days until due field in the Start Workflow modal will populate accordingly. If the calculated due date spans across multiple days because of the regional business hour differences, then a note will appear that says, "The selected users have different timezones so the due date ranges from <earliest due date and time>
- <latest due date and time>
." If the publication coordinator later wants to set a specific due date on the activity without accounting for any regional or business hour differences, they can then select a date in the Due Date field, which will automatically clear and ignore the Business days until due field.
Type
Activity type is configured using the CM_Type__c
field. Activity types include:
General activity. General activities are either pending or complete. When the user opens the activity modal, the
Mark as Complete
button displays.Approval activity. Approval activities require an
Approve
orReject
verdict.
Workflow Stage Transitions
Workflow Stage Transitions are the criteria that must be met to move a workflow to a different stage. Workflow Stage Transitions are defined in the CM_Workflow_Stage_Transition__mdt
custom metadata type. You can associate many Workflow Stage Transitions to a single Workflow Stage. For a list of Workflow Stage Transition fields, visit Workflow Stage Transition.
Key concepts
Workflow Stage Transitions dictate how and when a workflow will transition between stages.
The
CM_Condition__c
field houses the logic that determines when a transition executes. Transitions occur when the Condition evaluates totrue
.The Destination Stage is the stage the workflow will transition to when the transition runs.
Note
The Destination Stage must be a stage under the same workflow as the current stage.
Conditions
Each Workflow Stage Transition has a condition in which the transition executes. The condition is a JSON document that must conform to the following:
The
path
property must reference theevent
,documentVersion
, ortask
object using dot notation.The
operator
property must beEquals
.The
value
property must be a Workflow Event Type. Visit Workflow Event Types.
Workflow Event Types
The following event types are valid enums to use when configuring transitions:
SingleTaskCompleted - published when a single non-approval workflow activity for the current stage has been completed.
AllTasksCompleted - published when all non-approval workflow activities for the current stage have been completed.
SingleReviewerApproved - published when the first reviewer marks their activity as
Approved
.AllReviewersApproved - published when all reviewers have marked their activities as
Approved
.SingleReviewerRejected - published when a single reviewer has marked their activity as
Rejected
.AllReviewersRejected - published when all reviewers have marked their activities as
Rejected
.
Examples
{ "path": "event.mvn__CM_Type__c", "operator": "Equals", "value": "SingleTaskCompleted" }
{ "AllTrue": [ { "path": "event.type", "operator": "Equals", "value": "AllTasksCompleted" }, { "path": "documentVersion.mvn__CM_Document_Type__c", "operator": "Equals", "value": "CM_Internal_Document" }, { "path": "task.KLS_Type__c", "operator": "Equals", "value": "some custom type" } ] }
Workflow Activity Capacity
The Workflow Activity Capacity (CM_Workflow_Activity_Capacity__mdt
) custom metadata type defines the capacities in which users act when reviewing workflow activities. For a list of Workflow Activity Capacity fields, visit Workflow Activity Capacity.
To configure a custom capacity for a specific Workflow Stage Activity, associate a Workflow Activity Capacity record to the appropriate Workflow Stage Activity record via the mvn__CM_Workflow_Stage_Activity__mdt.mvn__CM_Workflow_Activity_Capacity__c
field.
Storing workflow data
When a workflow is activated, the Workflow Instance (mvn__CM_Workflow_Instance__c
), Workflow Instance Stage (mvn__CM_Workflow_Instance_Stage__c
), and Workflow Instance Document (mvn__CM_Workflow_Instance_Document__c
) custom objects begin storing information about the activated workflow. More specifically, a Workflow Instance record is created to track the workflow's progress, and a Workflow Instance Stage record is created each time the workflow transitions to a new stage. The Workflow Instance Document contains a list of documents associated to the workflow.