Workflows Best Practices

General

Single Application

  • Avoid workflows that cross applications.

Naming Conventions

Workflow Properties

  • Description: Use the Description field to describe what the workflow does. ReadiNow consultants normally put a specific label on the first line of the Description such as the form name where the workflow will be used or any specific area which makes it easy to know where the workflow will be used.
  • Applications: This is the application that the workflow belongs to. Do not leave this blank unless the workflow is actually generic and does not belong to any particular application.
  • Owned By: By default this will take the name of the creator. The best practice is to then change it to the name of an Administrator user that will always be present and not disabled or deleted as admins leave the company. The user account must have adequate privilege to run any task required by the workflow such as deletion or access to secured records.

Break complex workflows into multiple workflows

  • Workflows are often used to model multi-step business processes. Each step may in turn require multiple workflow activity steps to be completed. Consider creating individual workflows to model individual business process steps, with a master workflow to call each of them in turn using the Run Workflow activity.

Use the Workflow Analyzer to review interdependencies between workflows

  • Workflows may cause other workflows to run, either by use of the Run Workflow activity, or implicitly by modifying records that in turn have a trigger set up to run another workflow. Take care to ensure that workflows are not designed in a loop that causes them to call each other.
  • The Workflow Analyser tool can be used to graphically show which workflows may cause other workflows to be started.

Designing Efficient Workflows

There is often more than one way to achieve a particular outcome. However, some patterns will tend to run more efficiently than others. The following patterns will generally result in workflows that run more quickly.

Use the Workflow Examine Run tool to investigate workflow efficiency

The Examine Run tool allows you to view the amount of time spent processing each activity in the workflow, and to drill down into the contents of variables.

The Start Activity

Workflows are used to automate tasks or manipulate selected records or a group of them. The workflow can either work on a selected record which is either the open record in a form, or the selected record in a report, or it can work on a collection of records that are read from a report.

To tell the workflow that you want to work on the selected record use the Input Parameter:

  • Name: if you have only one record source then you can remain with the default name of ‘Input’. Otherwise give this a name that would help distinguish the input parameter from another. For example you can use ‘Incident Input’ or ‘Risk Input’ to indicate that one parameter is related to an Incident and the other to a Risk object.
  • Type: The Type tells the workflow what kind of input the workflow is dealing with. The workflow can operate on a selected record or on information passed on from other workflows. The most common use of the Input Parameter is a Record Argument which means the Input value will be a selected record. If you want to handle a set of records then set the Type to Record List. The other types, can be used to specify what is the nature of the value passed to the workflow. This is when the value is passed from yet another workflow.
  • Definition: This is where you specify what object will the record source hold. If you want to run the workflow on an Incident form then your Definition should have Incident in it. Note that once the workflow is saved you can show the workflow as a button on the object form by  using Actions.

The Submit Incident workflow (second line in Record Actions list) will appear in this list because the workflow has the same object as the form.

Note: there is no need to add any Input Parameter if the workflow will not get any input from a selected record. For example when all the records fetched will come from a ‘Get Records’ activity.

Use the Get Records activity to get a filtered list of records

When to use:

If you need to need to process all records of a particular object that meet some criteria, such as having a particular status or field value, then use the Get Records activity to load the records from that report.

This is particularly helpful for objects that have a very large number of records, even if only a small number of those records will match the criteria. At present this approach will generally run more quickly than writing an equivalent calculation in a workflow.

How to use:

  1. Create a  report and add analyser conditions to perform the required filtering.
  2. Add the Get Records activity to the Workflow to load the records.
    • Optionally, Workflow variables can be used to control analyser conditions to perform filtering relevant to the current workflow run.
  3. Use the [Get Records.List] output of the Get Records activity as needed, for example in an Update activity or Loop.

Provide a list of records to the Update and Create activities to update multiple records at once

When to use:

If multiple records are being processed and having fields and lookups set, then it is possible to provide a list of records as the input to the Update activity. The calculations used for setting field and relationship values may make reference to other fields and relationships on the individual record.

When the update activity is used in this manner, the records will be processed in batches and this is typically more efficient than writing an equivalent workflow that uses the loop activity to check each record in turn.

How to use:

  1. Provide a list parameter or list calculation to the Records input of the Update activity.
    • The [Get Records].List output of a Get Records, as described above, can be used here.
  2. The calculations for each field and relationship may make direct reference to existing fields and relationship on the record.
  3. For example, the Name record of a person record could be updated with the calculation: [First Name] + ' ' + [Last Name]

The same technique can be used with the Create activity by providing a list of records to the 'Based On' input of the Create activity.

Use the Create Activity in combination with Resource Keys to create/update records

When to use:

A common workflow requirement is to retrieve data from an external source, such as by making an API call, or processing a spreadsheet. This data is then used to create and/or update records. Typically there is some form of identity field or ID number, and if a pre-existing record has the same number then it needs to be updated, but if the is no pre-existing record then one needs to be created.

The most efficient way to perform the combined task of: checking for an existing record, updating the existing record, or creating one if it does not already is exist, is to use a Create activity in conjunction with a Resource Key.

How to use:

  1. Create a Resource Key for the object that indicates that a particular ID field on the record will uniquely identify records.
  2. In the Workflow, add a Create activity (not an update activity) to create records of the required object.
  3. Enable the Create activity option "Update existing record with matching key". Note: this option will only appear if an object is selected that has a resource key defined on it.
  4. Set a value for the field (or all of the fields and relationships) that make up the resource key.
  5. Set any other field or relationship values that need to be set.
  6. Optionally:
    1. As described above, a list of record can be provided as the input to the Create activity, which will cause the create/update operations to be performed in batches.
    2. And ideally this list input should be the List output of an earlier Get Records activity.

Take care when using loops

If a workflow has a loop that runs over a large number of records, then the workflow may take a long time to run.

  • Where possible, use techniques such as those described above to avoid needing to use loops.
  • If a loop is unavoidable, then examine activities and calculations that are within the loop. If there are any calculations - or parts of calculations - that are essentially the same for each record in the loop, then consider performing those calculations before entering the loop, and assigning the result to a workflow variable.
  • This means that the calculation does not need to be performed for each record in the loop. This can save considerable time.

Take extra care when using nested loops

If a workflow has a loop that in turn contains another loop, then the time required to run the workflow may be proportional to the number of records in the outer loop multiplied by the number of records in the inner loop. This can be a large number in some cases.

If this type of nesting cannot be avoided then, minimally, carefully examine each calculation and activity as described above. Ideally move common calculations to before the outer loop. However if this cannot be done, then minimally move common calculations from within the inner loop to just before the inner loop.