Retrieve custom field info from issue's parent link issue
Asked by T?th Tam?s:

Hello there!

I have an issue and it has the parent link set. I want to retrieve a custom field value from the issue which is in the parent link. Basically I want to compare the two custom field values whether they are the same in the issue and the issue in the parent link.

My custom field is a single select dropdown field.

{{issue.parent link.customfield_xxxxx}} did not work.

I tried with other fields ( {{issue.parent link.assignee.displayName}} and {{issue.parent link.assignee}} ) they did not work either.

However {{issue.parent link}} gave back the key (with a link) of the issue in the parent link

My company is on datacenter 9.4.11 and we have ScriptRunner.

Thanks in advance!


Answers:
author: Bill Sheboy
body: Hi [@T?th Tam?s](/t5/user/viewprofilepage/user-id/5567336) -- Welcome to the Atlassian Community!

When an issue links to others (e.g., such as with Parent, Parent Link, or issue links), an automation rule *does not necessarily load all of the data for those linked-to issues*. If it did, you could imagine a scenario where a single issue connects to many others, perhaps all of them in the site!

The way to know what is available is by experimentation: create a test rule to access the field and write it to the audit log. If it is present, you may use it. If not...

The solution depends upon what you need to do, and as you describe using Jira Datacenter, the options are limited for automation rules:

1. If you only need to view the field, such as for sending an email, use a branch to the issue
2. If you need the information for editing another issue, or your rule already uses branches, you would need to call the REST API issue search with JQL using the Send Web Request action.

For Jira Cloud, the other option is using the Lookup Issues action with JQL to access the field. That will not work for Jira Datacenter as most fields are not yet supported for that action: <https://jira.atlassian.com/browse/JIRAAUTOSERVER-877>

Kind regards,  
Bill

comments: author: T?th Tam?s
body: Hy Bill!  
Actually I'm playing with this rule in a dev environment, and tested a lot, but I just ran out of ideas, and wondered if am I doing something wrong, or simply it is just not possible.

Fortunately I don't need to edit other issues based on the information, just a notification email would be more than enough (see the whole automation in my other reply).

By "use a branch rule" you mean creating a "branch rule / relating issues" component? Then which type of related issues should I choose (none of them seemed appropriate for the parent link)?  
I have the following options: current issue, sub tasks, parent, stories (or other issues in epic), epic (parent), all created issues, most recently created issue, linked issues, destination issue, JQL, issues in fixed version, issues in sprint


author: Bill Sheboy
body: Without seeing your entire rule for context, you could use a branch on JQL to access the issue.

If that does not help, please post an image of your complete rule, and images of any relevant actions, to provide more context.


author: T?th Tam?s
body: Here is the full automation:

![automation.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/341962i229FDE290558378E/image-size/large?v=v2&px=999 "automation.PNG")

The third "Else-if: all match" part is the tricky one. If the epic is created, and the parent link is set, then I would like to retrieve issue's (which is set in the parent link) customfield.  
{{issue.parent link}} works fine, returns the issue's key  
{{issue.parent link.customfield_11801}} returns blank

As you just wrote in your first reply, maybe it is just not accessible.


author: Bill Sheboy
body: Thanks for that information. It does appear you will need to branch to the parent first, however...Given the limitations of rules, an if / else condition cannot be placed inside of a branch.

One workaround for your scenario is to capture the parent field first, such as like this to compare the id of the selected value:

* trigger: issue created
* action: re-fetch issue
* advanced compare condition: *This will confirm there was a parent linked value before proceeding.*
  * first value: {{issue.Parent link}}
  * condition: does not equal
  * second value: *leave this empty*
* action: create variable
  * name: varParentCustomField11801
  * value: NULL
* branch: to the the parent linked issue, such as with JQL
  * action: create variable
    * name: varParentCustomField11801
    * value: {{issue.customfield_11801}}
* if / else condition structure...
  * *perform your tests, substituting in {{varParentCustomField11801}} in the place of the parent value for the checks.*


author: T?th Tam?s
body: I'm afraid I don't have the create variable action since we are on data center, and as far as I know this feature was only implemented on cloud.


author: Bill Sheboy
body: The create variable action is available for Jira Cloud and Data Center versions of automation:

<https://confluence.atlassian.com/automation/jira-automation-actions-993924834.html#Jiraautomationactions-create-variableCreatevariable>

This action was added in August 2023 with version 9.0.0 - 9.0.1. Please check with your Jira Admin on your current version and if it needs to be updated.

<https://confluence.atlassian.com/automation/jira-data-center-automation-release-notes-1018767858.html#JiraDataCenterautomationreleasenotes-9.0.0-9.0.19.0.0-9.0.1>


author: T?th Tam?s
body: Indeed, you are right. I thought our JIRA core and Automation for JIRA plugins version numbers are the same, but it turned out they aren't. As you advised, we need to update it, and with the help of variables, I'm sure I will figure out a solution.

Thanks for all the replies and help!


author: Marc - Devoteam
body: Hi [@T?th Tam?s](/t5/user/viewprofilepage/user-id/5567336)

Welcome to the community.

Could you please provide your automation rule as well. This will help community members to understand the logic of the rule and help you the find a solution.

But I think you need to look from the parent to the linked issues and and then compare.

comments: author: T?th Tam?s
body: Hy Marc!  
Sure, here it is:  
![automation.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/341660iDDDB876B8F40E69F/image-size/large?v=v2&px=999 "automation.PNG")

Basically what I want to achieve with this automation it to make sure colleagues follow the correct structure we implemented. We use advanced roadmaps so our hiearchy looks like this:  
Business concept -\> Increment -\> Epic -\> standard issue types -\> sub issue type  
We have a custom field called related project and we use this field to mark all the issues that belongs to a specific project and in all levels it should have the same value (e.g. if an increment belongs to "project x" than all the issue under it must belong to the same project). We use this field for a lot of other processes so it's important to set them properly but unfortunately people sometimes mess this field up thus breaking the structure.  
With the automation I want to receive an email if on any level, the given customfield is not the same, as the element above it.  

The first "IF" statement examines the created subtasks, whether it has the same customfield value as the element above it.

The second "IF" statement does the same, but for standard issues. It examines if the given issue has the same customfield value as epic above it.

And with the third "IF" statement came the problem, I could not retrieve the issue's customfield value which is set in the parent link.

According to this thread ([How to access parent link issue's fields (atlassian.com)](https://community.atlassian.com/t5/Jira-questions/How-to-access-parent-link-issue-s-fields/qaq-p/2103053)) at least retrieving the assignee should work, that is why I thought it should work with customfields too. Unfortunately neither of the worked for me.

And thanks for the recommandation, maybe I will create a separate automation which will examine the "higher" level's child issues and see if those work.


author: Marc - Devoteam
body: Hi [@T?th Tam?s](/t5/user/viewprofilepage/user-id/5567336)

What if you would set the last else condition to:

{{issue.Parent Link.customfield_11108}}


author: T?th Tam?s
body: Unfortunately it just returns nothing.  
I also tried these two variations:  
{{issue.Parent Link.customfield_11108.value}}  
{{issue.Parent Link.customfield_11108.data}}  

still no success.

Anyway, it is not a big deal if I can't do (or can't be done) with automation, I can reach jira's DB so I will create a report based on that.


Tags: cloud

jira-cloud