Integration with Jira Insight Assets
Now, within a condition rule, you can dynamically retrieve all relevant deciders referenced by single—or multi-user custom fields, project roles, Jira groups, and user-based attributes of Jira Insight Assets.
Please use the following sample code and adjust lines #2, #3, and #4 according to your environment. The variable assetAttrName
contains the name of the asset’s attribute with the related users. The variable validStatus
represents the issue status, being valid for a decision as a pre-requisite. The custom field cfAssetsObject
specifies which Jira Insight Assets objects are used for a Group Sign-Off.
// conditional rule
const assetAttrName = "Approvers";
const validStatus = "waiting for approval";
const cfAssetsObject = "Branch";
users = "";
rule = "";
if (issue.status.name == validStatus) {
var assetsStakeholders = helper.getCF(issue, cfAssetsObject);
assetsStakeholders?.forEach(stakeholder => {
const asset = helper.fetch(`https://api.atlassian.com/jsm/assets/workspace/${stakeholder.workspaceId}/v1/object/${stakeholder.objectId}`);
const attribute = asset?.attributes?.find(attr => attr.objectTypeAttribute.name == assetAttrName);
const cmdbUsers = (asset ? attribute?.objectAttributeValues.map(attr => attr.user.key.replace(/:/g,"__").replace(/-/g,"_")).join(`/* ${asset.label} */, `) + `/* ${asset.label} */` : '');
if (cmdbUsers) {
users += (users.length ? ', ' : '') + cmdbUsers;
rule += (rule.length ? ' AND (' : '(') + cmdbUsers.replace(/, /,' OR ') + ')';
}
});
}
As an admin, you must authenticate yourself once by email address and API token within the app’s global configuration. These data are used to access Jira Insight Assets via the method helper.fetch().
Having done this, you will get the approvers for a Group Sign-Off out of the referenced Jira Insight Assets: