Starting an automation but only when a specific field has a specific value

Lance Shaw December 22, 2022

I have 2 projects.  When a ticket is raised in project1, a ticket is auto created in project2 and added as a linked item. the project 2 ticket is only created and linked if a specific field has a specific value.

The issue us that project 1 is used for other tickets also and we are nearing our monthly quota for executions.

Ideally, I only want the automation rule to run is a specific field has a specific value. (for some reason I cannot add a screenshot).

The rule starts off with 'When: Issue created' so it runs every time

Any ideas would be appreciated.

 

4 answers

1 accepted

0 votes
Answer accepted
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.
December 22, 2022

Hi @Lance Shaw 

From what you described, I suspect you are running this as a global/multi-project scope, rather than a single project scope rule.  Is that correct?

If so, you can do what you need with a project scope rule, eliminating the need to use up your rule execution limit for global rules.

For example:

  • trigger: issue created
  • action: re-fetch issue (This can help to slow the rule and reload the data.  Sometimes the issue created trigger runs too fast.)
  • action: create a new issue, selecting the other project
    • set the fields as you need, perhaps copying from the trigger issue
    • to link the uses, use the advanced edit with JSON, such as this
{ "update": {
"issuelinks": [
{
"add": {
"type": {
"name": "Relates"
},
"outwardIssue": {
"key": "{{issue.key}}"
}
}
}
]
}
}

 

Kind regards,
Bill

Lance Shaw December 29, 2022

Thanks for that Bill. This works without using the execution limit. Struggling with the second part though.

The status of project1 updates and I need to update the status of a linked issue for project 2 to the same status.

I've started it with Issue Transitioned and then use a Branch Rule/related issues object and then a JQL statement of 'project = project2', but as this Rule is in project 1 it does not seem to see project 2. In the audit log, it shows 'No related issues could be found'

any pointers please

Regards Lance

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.
December 29, 2022

A project-scope rule cannot transition (or make any edits) to issues in another project directly.

You would need to use a global/multi-project scope rule to do so...and that will be impacted by the limits of your Jira Cloud license level.  In general, I suspect such a rule would viable for a Premium license, as it can have a lot more global rule runs per month.  For other levels you could quickly run out of your limits.

One possible work-around is to have the project-scope rule make the transition by calling the REST API method: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-transitions-post

If you want to try that, here is a how-to article for calling the REST API from a rule: https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828

0 votes
Rilwan Ahmed
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 22, 2022

Hi @Lance Shaw ,

Welcome to the community !!

The automation rule will trigger for every ticket created irrespective of conditions, but it wont create a new ticket until the given condition is met.
We cannot make rule to run when only particular ticket is created.

Lance Shaw December 22, 2022

Hi Rilwan

Is there not a conditional trigger or some JQL that would allow this?

Rilwan Ahmed
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 22, 2022

Hi @Lance Shaw 

You can try creating new rule as below

Trigger == Issue created
New condition == Issue fields condition, select labels field and the value required.
New Action == Create issue

image.png 

Please note: The rule will for all tickets created, but linked issue will be created only when the condition given is met.

Lance Shaw December 22, 2022

Hi Rilwan

Will that not still run every time an issue is created?

I'm looking at using a schedule trigger to run maybe every 2 hours and then proceed with creating a new ticket if the condition of the schedule is true.

So we can have up to 100 tickets a day created and at present, that will run the rule 100 times.  If we have a schedule for every 2 hours then this will only be 12 times.

Our monthly execution is set to 500 so just this one rule could exceed that value in a week as it's currently set

Rilwan Ahmed
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 22, 2022

Hi @Lance Shaw 

1. Will that not still run every time an issue is created? 
-- Yes, it will run. But it will not impact anything unless you have 100s ticket created in very short time like 1-5 minutes. 

2. You can. Use Scheduled trigger and JQL can be 
created >= -2h and labels = 'sample-space'.  Modify the JQL as required for you. 

image.png

0 votes
Tara Mullen-Boustiha December 22, 2022

Hi Lance,

Could you try using the trigger "field value changed"?image (76).png

Lance Shaw December 22, 2022

Hi Tara

The issue is the field holds the value when the ticket is created.

Also the field in question is called label and a label is added at various parts of the tickets life so each time a label is added, then the rule will still run

0 votes
Lance Shaw December 22, 2022

Rule.png

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events