ProForma Automation Rule on Request Create

In scenarios where ProForm automation is executed on request create on a JSM request, issues can arise since automation actions configured on create run in parallel with ProForma. This can lead to forms disappearing, or data not being written to linked Jira fields when they are read by other automation systems.

Workaround

An intermediary status added to the workflow can help get around these problems.

Before an intermediary status, the workflow might look like this:

  • Request created on JSM portal with the desired status (eg "To Do")

  • ProForma automation adds and submits form immediately after create

To fix this, an intermediary status is reached before the “To Do” status. This workflow might look like:

  • Request created on JSM portal with an intermediate status (eg "Processing")

  • ProForma adds and submits form immediately after create

  • ProForma form automation configured on submit of the form transitions to the desired status (eg "To Do")

  • Automation actions configured on transition to status "To Do" run after ProForma

Jira Automation or Third-party Automation Tools

Customer portal forms and Issue Forms allow you to create Jira issues directly from ProForma forms.  However, the order in which the events are executed can cause automation to fail. This problem has been observed with JSD Automation, Project Automation (formerly Automation for Jira), ScriptRunner for Jira, and Power Scripts, and is likely to occur with other automation tools.

Order of Events

The cause of the problem can be seen in the order of events when a Jira issue is created from a form and the automation is executed.

  1. Data is entered into the ProForma form.

  2. The form is submitted and an issue is created.

  3. Automation executes, trying to read data from the ProForma form and linked fields.

  4. The ProForma form attaches to the issue and writes data to linked field on the issue.

As indicated in steps 3 and 4, automation attempts to read data from the ProForma form before it has been written to the Jira issue. This means there will be no (or null) data, and the automation will fail. 

Solution – Add a Delay

You can solve this problem by adding an arbitrary delay to the beginning of the automation. A delay of 1000-5000 milliseconds will ensure that the ProForma data has been written to the issue by the time the  the automation executes. Thus the order of events will be:

  1. Data is entered into the ProForma form.

  2. The form is submitted and an issue is created.

  3. Automation sleeps

  4. ProForma form attaches to the issue and linked field data is written to the issue.

  5. Automation executes successfully.

In ScriptRunner for Jira, placing the sleep() function at the beginning of the script will achieve the appropriate delay. 

Example Project Automation/Automation for Jira

In the example below, a form field linked to the Jira Summary field triggers the rule for issues created within the last minute.

Example Groovy Script - ScriptRunner for Jira Cloud

Example.groovy

sleep(2500)

def getPFVal(issueKey, customField) {
    // Fetch the issue object from the key
    def issueOne = get("/rest/api/2/issue/${issueKey}")
            .header('Content-Type', 'application/json')
            .asObject(Map).body

    def issueOneFields = issueOne.fields as Map

    return issueOneFields[customField] ?: 0
}

def ids = ["JSD-85", "JSD-84"]

ids.collect{getPFVal(it, "customfield_10053")}.sum()

CODE

 

Automation Tool Docs
Consult the documentation of your favorite automation tool to learn how to add the necessary short delay. 


Alternative Solution - Add a Status

You can also add a status to ensure there is time for ProForma to update linked fields before the automation is triggered. In this example, a PENDING status is added and an automation rule is triggered depending on the value of a linked field.

 

  1. Amend the workflow to include extra “Pending” status between the first status and the status that will trigger the automation.

  2. Set up ProForma Automation to automatically transition the issue to the next status (WORK IN PROGRESS) once the form is submitted. This will move your issue to the target status while ensuring that all linked fields have had time to update.

  3. Set the desired automation rule to be triggered by the status the issue has just reached.