Configure a custom Display View (Live fields only)
Problem
A Live field contains several views:
- The Edit view, for selecting values in the create/edit/transition screens.
- The Display view, for displaying values in the issue view, search results, dashboards, etc.
- The Search view, for searching values in the Issue Navigator.
The Display view displays the values previously selected in the Edit view. It's therefore useless to retrieve all available values:
- When only one value is selected, only that value should be retrieved, and there's no need to retrieve the others.
- When no value is selected, there's nothing to be retrieved, so the datasource is not contacted
To do so, you need to configure a custom Display view query.
Useful variables and functions
To complete this use case, two variables should be used:
- $currentCustomfieldValue: This variable contains the value currently selected in the field. It corresponds to the key you set in your Connect field and is stored in Jira.
- $query.abort(): This function cancels the query execution. When executed, the datasource is not contacted.
The different cases
Two cases are possible, depending on your Connect field configuration:
Case A: when the key and the template are different
When the key and the template are different, the value stored in Jira (the key) doesn't match the value to be displayed (the template). In this case, you need to contact the datasource to retrieve the display value.
In this case, you need to configure a custom Display view query using $currentCustomfieldValue. This will filter the query and ask the datasource to return only the value that matches the key stored in Jira:
Here is how to proceed:
Edit your Connect field
Check if the key and the template are different
Then, go to the Display view tab
Check the box called "Configure a specific query"
Write a query depending on $currentCustomfieldValue, such as:
CODESELECT * FROM jiraissue WHERE id = $currentCustomfieldValue
Case B: when the key and the template are the same
When the key and the template are the same, the value to be displayed (the template) corresponds to the value stored in Jira (the key). It's therefore useless to retrieve this value from the datasource because it's already stored in Jira.
In this case, you can directly execute $query.abort() in the Display view, as below:
Here is how to proceed:
Edit your Connect field
In the Edit view tab, check if the template and the key are similar
If the template and the key are the same, go to the Display view tab
Check the box called "Configure a specific query"
Write the following query:
CODE$query.abort()
Save your changes
If your field is single-value, you can also use a Snapshot field, as the datasource is contacted only when it's created/edited. When it's displayed, the data is read from the Jira database.