Create Asset
This feature is currently in Beta. If you have any feedback for us, please add a comment to SRJIRA-6849.
We’ve provided an easy way to create Insight/Asset objects in Automation for Jira. For example, you can use the Create Asset with ScriptRunner action to create a new Assets object when a new issue is created.
When you use this action, make sure you specify object type and attributes in JSON format.
Once you have added the Create Asset with ScriptRunner action, you can reference attributes of the Assets object in another action using the {{createdObject}}
smart value (see step 10 in the example below for a working example of how to use this smart value).
Using {{createdObject}}
you can retrieve the attribute values, in addition to other important object values. For example:
{{createdObject.objectKey}}
{{createdObject.id}}
{{createdObject.attributes.Name}}
{{createdObject.objectType.name}}
Obtaining attributes
If you wish to discover more attributes, you can add Log action to a rule that contains the Create Asset with ScriptRunner action—{{createdObject}}
must be added as the value in the Log action. Once the rule has run, you can check the audit log and it will display available attributes for you to use.
Retrieving object attributes using smart values is helpful in many contexts. For example, you can add a comment that links to the created object, as shown in the example below.
Example: Create Assets objects on issue creation and add a comment
In the following example, we want an Assets object to be created when a new issue is created. In addition, we want a comment to be added to the issue that links to the created object.
The following example uses attributes and objects from the Sample IT Asset Schema template. If you are using your own schema, make sure you replace any mentioned names with those that match your own objects and attributes.
- In Automation for Jira, select Create rule.
- Select Issue created as the trigger.
- Select Save.
- Select New action.
Scroll to Miscellaneous and select Create Asset with ScriptRunner.
Enter the object type and any attribute values, in JSON format, into the Attributes text box. In addition, if you use values from the current issue, make sure you use the JSON-escaping functions for smart values.
Examples are provided for you below the Attributes text box.
- Select Save.
- Select New action.
- Under Issue actions, select Comment on issue.
Enter a comment for this issue and use the
{{createdObject}}
smart value to reference an attribute of the created object. In this example, we want to create a comment that links to the created object, so we enter the following:A new object has been created ({{createdObject.objectKey}}): * {{baseUrl}}/secure/ObjectSchema.jspa?typeId={{createdObject.objectTypeId}}&objectId={{createdObject.id}}
- Select Save.
Name the automation and select Turn it on. In this example we name the automation
Create Object Rule
.
An Assets object will now be created every time a new issue is created.