How do I import risks from a CSV file?

This page applies to Risk Register for Jira Cloud

Suppose you have an MS Excel spreadsheet containing your risks, and you'd like to import them into Risk Register; can it be done?

While you can import most fields into Jira from a CSV, you cannot import the impact and probability values directly into custom fields. Risk Register stores those values in entity properties, and merely updates the values of the custom fields to correspond with the entity properties. The image below shows the output of the Entity Property Tool for Jira, which reveals the entity properties for a particular risk issue.

Risk Register has a background task that picks up the assessment from the entity property when you change it, and sets the values on the Inherent impact and Inherent probability custom fields.

What this all means is that you have three possible ways to set the impact and probability values:

a) Set them in the standard way via the user interface; or
b) Install the Entity Property Tool, and use it to update the entity properties; Risk Register will then set the custom field values; or
c) Use Jira's REST API to set the entity property values, possibly being called from a tool like ScriptRunner.

The following is a ScriptRunner code snippet that sets the risk values for a risk with issue id NTP-5:

def issueKey = 'NTP-5'
def impactId = 3
def probabId = 3
def propertyKey = 'pbrr-assessment'
def propertyValue = '{ "schema-version": 1, "inherent": { "impact": { "id": ' + impactId + ' }, "probab": { "id": ' + probabId + ' } } }'

def result = put('/rest/api/2/issue/' + issueKey + '/properties/' + propertyKey)
.header('Content-Type', 'application/json')
.body(propertyValue)
.asString()

return "${result.status}: ${result.body}"

The values for impact and probability in the risk assessment are the IDs of the corresponding impact and probabilities in the risk model. The number is not regular, and so the best way to determine what those IDs are is to adjust the impact and probability via the slider controls, and then view the issue entity properties via the Entity Property Tool.

This slightly more sophisticated script looks up the impact and probability values in a list and then assigns them to the issue.

def issueKey = 'NTP-5'

def listImpacts = ['Severe', 'High', 'Medium', 'Low', 'Negligible']
def listProbs = ['Very unlikely', 'Unlikely', 'Likely', 'Very likely', 'Almost certain']

def impact = 'Medium'
def probab = 'Likely'

def impactId = listImpacts.indexOf(impact) + 1
def probabId = listProbs.indexOf(probab) + 1

def propertyKey = 'pbrr-assessment'
def propertyValue  = '{ "schema-version": 1, "inherent": { "impact": { "id": ' + impactId + ' }, "probab": { "id": ' + probabId + ' } } }'

def result = put('/rest/api/2/issue/' + issueKey + '/properties/' + propertyKey)
        .header('Content-Type', 'application/json')
        .body(propertyValue)
        .asString()

return "${result.status}: ${result.body}"

ProjectBalm does plan to add an import-from-CSV feature in a future release; but for now, the above options may provide an interim solution.