Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get the previous value of "Parent Link" key?

Mohammad Gharehyazie October 18, 2023

Hello All,

I am trying to write an automation rule that is supposed to go like this:
When: A task's "Parent Link" has been edited.

What: Do something to the previous parent and the current parent.

To perform an action on the current parent, I just create a branch with JQL query set to: 

key = {{issue."parent link"}}

Side note: I cannot use a regular parent attribute as I am using a custom issue hierarchy, but that is not the issue. The above mentioned code works.

 

To perform an action on the previouse parent, I have to create another branch. Currently the query looks like this:

 

key = {{changelog.Parent Link.fromstring}}

 

The problem is with the formatting of the return value. For example, if a task has the key "SE-2" and it's summary is "test task", I expect (or want) to have "SE-2" from the right-hand side of that expression (the changelog part) but it returns "SE-2 test task". It concatenates the description to the end of the key. How can I only get the key part? Or how can I compare it to the combination of key and summary at the left-hand side?

4 answers

1 accepted

0 votes
Answer accepted
Boldizsár Vermes
Contributor
October 19, 2023

@Mohammad Gharehyazie, have you tried {{fieldChange.fromString}} instead of changelog?

If it does the same, then, and I know, it's a hack, but use {{changelog.Parent Link.fromString.substringBefore(" ")}} to get the key only of the previous parent.

Mohammad Gharehyazie October 21, 2023

Thank you. The hack worked like a charm. I am so grateful.


BTW, fieldChange did not make any difference, same value returned. I believe the issue is caused because the "Parent Link" is displayed in Jira as a concatenation of Key + Summary, thus the fieldchange would still have both of them in the string.

Like Boldizsár Vermes likes this
TS
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 27, 2025

This doesn’t work for me on Jira Cloud

0 votes
Michele Imperiali
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 2, 2025

I'm adding my experience to this thread since I was able to make it work.
I've just implemented this rule in order to update iteratively the parent original estimate when a child is moved (so I have to access both new and old parents). 
Looking at the changelog, when an issue is moved from one parent to the other I have the following data:

{IssueParentAssociation=[ChangeItemBean{fieldId='null', field='IssueParentAssociation', fieldType='null', from='14241', fromString='TSBPL-222', to='13520', toString='TSBPL-113'}]}

So to access the id of the old parent I simply created a variable "oldParentVar" with the code below:

{{changelog.IssueParentAssociation.fromString}}

I then use the value of this variable to access the parent via this JQL code:

key={{oldParentVar|"null"}} 
TS
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 27, 2025 edited

Hi Michele, which version of Jira are you using?

I’m trying to do the same thing, using Jira Cloud, & I don’t get any results (tried various ways).

When I examine the changelog JSON via the API, I do see the below, shortened to the relevant portions:

{
“changelog”: {
“histories”: [
{
“items”: [
{
“field”: “IssueParentAssociation”,
“fromString”: “ABCD-1234”

My rule is structured to be manually triggered from an issue & then act on each child:

- when manually triggered

- for each child

- create variable {{previousParentKey}}

- log: value {{previousParentKey}}


For the smart value for the variable, I’ve tried:

- {{changelog.IssueParentAssociation.fromString}}
- {{issue.changelog.IssueParentAssociation.fromString}}
- {{issue.parent.fromString}}
- {{changelog.parent.fromString}}
- {{issue.changelog.parent.fromString}}
- {{issue.IssueParentAssociation.fromString}}

All of the above with using Parent instead of parent, or issueParentAssociation instead of IssueParentAssociation. Also instead of doing it on the children of a given issue, doing on the issue itself.

none of them work :/

Michele Imperiali
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 1, 2025

Hi, I'm also using JIRA Cloud.

Looking at your changelog, it looks like you have to access the value like this:

{{changelog.histories.items.fromString}}

0 votes
Erin Quick-Laughlin
Contributor
October 18, 2023

@Mohammad Gharehyazie what happens if you capitalize the 's' in fromstring to fromString?

This is working for us...

Screenshot 2023-10-18 140911.png

Mohammad Gharehyazie October 18, 2023

Thank you for your reply, but it did not make any difference. It still returned (Key + Summary). I am basing my findings on the error report of the audit log.

Erin Quick-Laughlin
Contributor
October 19, 2023

What is in the changelog when you log it via the rule?

Mohammad Gharehyazie October 21, 2023

I do not know how to answer that.

All I know is when I used my expression below, when the key was "SE-3" and the summary was "First story", I expect "SE-3" as the result but it evaluates as "SE-3 First story" and thus throws an error.

{changelog.Parent Link.fromstring}}

 Apparently the word "first" is a reserved keyword, but that is not the important thing here.

I would be more than happy to try whatever commands you ask me of, but you have to guide me through. How do I get the changelog?

Boldizsár Vermes
Contributor
October 21, 2023

Just log the {{changelog}} full value and show us the result.

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2023

Hi @Mohammad Gharehyazie -- Welcome to the Atlassian Community!

The change log for a specify field returns that field, and so the syntax you are using may be creating some other string.

Perhaps try: {{#changelog.Parent Link}}{{from}}{{/}}

Kind regards,
Bill

Mohammad Gharehyazie October 18, 2023

Thank you for your reply, but it did not work. It returned empty (or something that could not properly be parsed as a string). I am basing my findings on the error report of the audit log.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Upcoming Atlassian Automation Events