Update a custom field with automation (or listeners)

Chiara Squilloni
Contributor
June 14, 2023

Hi community,

I need a big help!

I am migrating jira server to cloud. We use Jira since 2015 and we have some addons, such as Scriptrunner and Jira Misc Custom Field (not aviable in jira cloud).

In detail we have two custom fields used in my company in all projects:

 - a field that store all the comment of a issue (date of comment, author of a comment and the comment itself)

- a field that store the date (day and time) in which a issue is been closed.

In wich way can I perform this in jira cloud?

I tried with automation rules but I can't solve it!

1 answer

1 accepted

0 votes
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 14, 2023

Hello @Chiara Squilloni 

Please show us with screen images what you have tried in your automation rules and explain how the results you are getting don't match your requirement.

Is the field you want to set a date field or a date+time field?

Jira issues include a Resolution Date field that is set when the Resolution field gets set in the issue and cleared if the Resolution field is cleared. The Resolution field is typically set when the issue transitions to a green/done status. Could you use that Resolution Date field as the indicator for when the issue was "closed"?

If you need to track that the date that an issue transitions to a specific Status value then you can use a rule like this:

TRIGGER: Issue Transitioned
From Status: leave blank
To Status: specify the status you want to track
ACTION: Edit Issue
Field to set: your custom date field
Value: {{now}}

 

Regarding storing "all comments", do you mean that you have a long text/paragraph field that you append each new comment to? If so, then you can use an automation like this:

TRIGGER: Issue Commented
ACTION: Edit issue
Field to set: your custom field
Value:
{{issue.<name of your custom field>}}
{{comment.author.displayName}} {{comment.created}} {{comment.body}} 
Chiara Squilloni
Contributor
June 14, 2023

Hi @Trudy Claspill 

thank you so much for your answer. 

I modify the rule but the trigger give me an error in the json formula. I give you the screenshot.

jira_cloud.png

Chiara Squilloni
Contributor
June 14, 2023

I also find out in the developer Atlassian a rest API to get all the comments: 

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-get

Instead about the closing date thank you for your feedback but in many worflow the closing date is not the resolution date, just because after a issue is resolved by a developer maybe a tester need to perform more test and than set the issue as closed.

Thank you so much, I'm in a learning jurney.

 

Chiara

Chiara Squilloni
Contributor
June 15, 2023

I did it with the update for the comment:

{"fields":{
"commenti":"{{comment.author.displayName}} {{comment.created}} {{comment.body}}"
}}

 

But this overwrite the field anytime I comment, so I have to change and use "update" but I have a Json error and I cannot figure what!

{"update":{
"commenti":{"add":"{{comment.author.displayName}} {{comment.created}} {{comment.body}}"}
}}

Chiara Squilloni
Contributor
June 15, 2023

Ok so, maybe I can seem crazy but I tryed to put this:

{ "update": { "commenti": [ {"add": "{{comment.author.displayName}} {{comment.created}} {{comment.body}}"} ] } }

and than I had the error that I cannot use "add" for my custom field (WHY???)

So I use set (I now that update + set = fields) and than I append the value recolling the last value of the issue:

{ "update": { "commenti": [ {"set": "{{issue.customfield_10037}} \n {{comment.author.displayName}} {{comment.created}} {{comment.body}}"} ] } }

and this work!

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 15, 2023

Do I understand correctly that you have solved your requirement related to comments?

And is your requirement related to storing the date the issue was closed also resolved?

If not, please let us know what problem remains. 

Chiara Squilloni
Contributor
June 16, 2023

Yes Trudy, 

thank to your help I managed the solution.

About the solution for the close date and time:

1. I create a date/time custom field named "Chiusura"

2. in the automation rules I chose the state of the transition (Done)

3. in the rule I chose modify the issue and set in other options {"fields":{
"chiusura":"{{now}}"
}} 

Best regards,

 

Chiara

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events