Display values from Assets objects

Display values from Assets objects

This article explains how to render attributes of Asset type objects connected to JSM requests.

 

Assets objects is a feature supported by JSM Premium edition and allows you to configure and maintain a collection of objects that work in a Map-like way. These objects may be used to represent physical entities, such as hardware, machinery or office buildings as well as non-tangible assets, like configurations, contracts etc.

 

To retrieve the Asset objects from JSM, Raley needs a special token which you as a Jira administrator must create in https://id.atlassian.com/manage-profile/security/api-tokens

 

Create the token and save it in a separate file. Then concatenate the token with your Jira administrator email that you used in the token creating following by colon like this:

jira-admin@company.com:MY_JIRA_ACCESS_TOKEN

 

Encode the whole string abote to base64 and add it to Raley properties with key API_TOKEN like this:

API_TOKEN=amlyYS1hZG1pbkBjb21wYW55LmNvbTpNWV9KSVJBX0FDQ0VTU19UT0tFTg==

 

Now, navigate to Jira top menu Apps → Raley Emails Notifications → Settings. In the screen that appears paste the API_TOKEN string into the "name=value pairs" textarea, like this:

 

Click on Save and now you're all set configuration-wise.

 

 

 

The common scenario is that a JSM request has a link to specific Asset object and we need to show it in a customer-facing notification. We'll use the field called "Linked Assets" as example in this tutorial.

 

Here's how you render its attributes in Raley:

 

1) In Issue field picker choose the field "Linked Assets". You'll be presented with a popup which contains code similar to the following:

#foreach($o in $!issue.fields.customfield_10050) $jirassimo.getAssetFieldValue($o.objectId, "ATTRIBUTE_NAME") #end

 

Note that our Linked Assets field is customfield_10050 and it is a array-type field that we need to iterate using #foreach statement

 

2) Replace the ATTRIBUTE_NAME placeholder by the name of the attribute you want to render. Let's say the attribute name is "OT1 attribute". In that case, our code should look like this:

#foreach($o in $!issue.fields.customfield_10050) $jirassimo.getAssetFieldValue($o.objectId, "OT1 attribute") #end

 

That's it! Preview the notification configuration and you'll see the value of connected Asset field's attribute "OT1 attribute".