JSM Data Center - Assets - How to configure Assets Object custom field based on another Assets Object custom field

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

This article describes a situation where as a Jira (Assets) admin you want to configure two Assets Object custom field where based on the value chosen in one custom field should decide the filtered values shown on another custom field. 

In this example, we're using the following set up:

  • We have two asset objectTypes: XX and YY
    • There are two XX objects: XX1 and XX2
    • There are three YY objects: YY1, YY2, YY3
  • XX contains an attribute called refYY which is a reference to YY objectType (with cardinality unlimited)
    • star Remember to have a unique, easily understandable object reference name in the Additional Value column e.g., "Reference from XX to YY"

 

    • (info) Please note the direction of the reference i.e., XX → YY (this is important because the solution would only work if the object reference is set up this way)

We have the following object XX → YY relations:

  • Object XX1 points to objects YY1 and YY2
  • Object XX2 points to objects YY2 and YY3


We have two Assets Object Custom fields:

  • XX Custom field for XX objects
  • YY Custom field for YY objects

Use Case:

Our requirement is to populate the available options on YY Custom field based on the chosen value(s) on XX Custom field.

  • If we choose XX1 object in XX Custom field, we want to see only YY1 and YY2 in YY Custom field
  • If we choose XX2 object in XX Custom field, we want to see only YY2 and YY3 in YY Custom field


This use case can be imagined in many different ways. For example,

  • let's say you have "Customfield A" called "Location" pointing to "Location" object type and "Customfield B" called "Offices" pointing to "Offices" object type. You want when a user selects "Location A" in "Customfield A",  the "Customfield B" should only show the "Offices" belonging to that particular "Location" object.
  • Alternatively, the same use case apply to a "Manager" → "Employee" object relations where based on the object chose in the "Manager" custom field, you want to only see the "Employee" objects who reports to that Manager.


Environment

Jira Service Management Data Center with Assets (previously known as Insight)

If you're looking for this configuration in Assets Cloud products please follow this article instead: JSM Assets Cloud : How to filter Assets object within a issue based on other object custom field storing multiple objects

Solution

Configuration for XX Custom field:

The XX Custom field configuration is simple - we just need to point the custom field to the XX objectType:

  • The Filter Scope (AQL) should be:
    • objectType = XX


Configuration for YY Custom field:

The YY Custom field configuration should be in such a way that it only shows the reference objects of YY objectType that relates to the XX object chosen in the XX Custom field. So it should be configured with the following:

  • The Filter Scope (AQL) should be to point to the YY objecttype:
    • objectType = YY
  • star The Filter Issue Scope (AQL) will do the trick like this:
    • object having inR(objectType = XX and Key IN (${customfield_10309${0}}), refType IN ("Reference from XX to YY"))


Things to remember:

The Filter Issue Scope (AQL) of the YY Custom field has a few things to unpack and understand:

  • Please change the customfield_xxxxx with the XX custom field's ID
    • Why? Using the customfield name instead of the ID will also work. However, if you have Translated custom fields where the system language is different from the admin's preferred language the name of the custom field may not match. Using the ID instead of name ensures that we're dealing with a static number that is not going to change based on user preferences
  • Please give the "refYY" attribute a unique name in the "Additional Value" column like "Reference from XX to YY"
    • Why? Because XX object may have more than one outgoing reference to YY objects and we want to uniquely identify which specific object reference is relevant in our use case


Referring back to our [UseCase:], now when we choose a specific value in XX custom field, only the YY objects referencing to that value are shown to the users. check mark button 

Last modified on Jan 16, 2025

Was this helpful?

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