How to set Issue security level depending on an Assets object attribute

Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

In some scenarios, Jira issues have Assets Custom fields added to screens. You would like to make Jira issues visible only for users which are members of an Assets object attribute.  
Assets
Custom field has a type attribute User.

Here we will share a solution but it will also require some custom scripts.

Environment

Assets or Insight Asset Management

Solution

The solution includes an issue-level security, Assets Post function and a custom script to be developed by customers.

Requirements

  1. Create a new 'User Picker' Jira Custom field
    • The field will be populated by the value of your Assets object and it will also be used when selecting the appropriate security level
  2. Add an Issue Security Scheme - Configuring issue-level security
    • When selecting 'Users / Groups / Project Roles' column, you need to select User custom field value and set it to the Jira Custom field created in Step #1
    • Ensure to set issues security permission in the project permission scheme. This permission allows a user to set a security level.
    • You can read more about it here Managing project permissions
  3. Assign the issue security scheme to a project
  4. Until this point, Insight or Assets are not involved in the configuration.
  5. Create an Assets Post function on Create/Update transaction to copy the value of Assets user attribute to the 'User Picker' Jira Custom field so the security level can be set.
    • Insight Post function: Set a Jira custom field with the attribute value from a selected object
    • Source custom field: Your Assets CF 
    • Insight Object Type Attribute name: Object attribute which hold the username
    • Target custom field: The new Jira CF created in Step #1
      Make sure the event occurs before an event called (Class: com.atlassian.jira.workflow.function.event.FireIssueEventFunction) which it's created by default and after (Re-index an issue to keep indexes in sync with the database). If you do not have them, please discard the alert.
  6. When an issue is created, Jira should only display issues to only users included in the 'User Picker' Jira Custom field which should be the same as your Assets CF.

Other Notes

  • The above solution works if users in the Assets Object attributes never get updated.
  • If the Assets-Object attribute gets updated, with the current configuration described in this article, 'User Picker' Jira Custom field value will not get changed and the issue will still be visible to the previous user.
    • A custom script is needed to fetch the Insight CF value (probably username) and then push it to 'User Picker' Jira Custom field value created in Step #1





Last modified on Jan 20, 2025

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.