Starting an automation but only when a specific field has a specific value
Asked by Lance Shaw:

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.


Answers:
author: Bill Sheboy
body: Hi [@Lance Shaw](/t5/user/viewprofilepage/user-id/5106966)

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](https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Linking-issues), such as this

```
{ "update": {
    "issuelinks": [
      {
        "add": {
          "type": {
            "name": "Relates"
          },
          "outwardIssue": {
            "key": "{{issue.key}}"
          }
        }
      }
    ]
  }
} 
```

Kind regards,  
Bill

comments: author: Lance Shaw
body: 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


author: Bill Sheboy
body: 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>


author: Rilwan Ahmed
body: Hi [@Lance Shaw](/t5/user/viewprofilepage/user-id/5106966) ,

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.

comments: author: Lance Shaw
body: Hi Rilwan

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


author: Rilwan Ahmed
body: Hi [@Lance Shaw](/t5/user/viewprofilepage/user-id/5106966)

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](https://community.atlassian.com/t5/image/serverpage/image-id/231726i13F9153A9B6FA513/image-dimensions/180x86?v=v2 "image.png")

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


author: Lance Shaw
body: 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


author: Rilwan Ahmed
body: Hi [@Lance Shaw](/t5/user/viewprofilepage/user-id/5106966)

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](https://community.atlassian.com/t5/image/serverpage/image-id/231750i74D2CCE9ED80B26D/image-dimensions/170x70?v=v2 "image.png")


author: Tara Mullen-Boustiha
body: Hi Lance,

Could you try using the trigger "field value changed"?![image (76).png](https://community.atlassian.com/t5/image/serverpage/image-id/231718iCFD48238C642586A/image-size/large?v=v2&px=999 "image (76).png")

comments: author: Lance Shaw
body: 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


author: Lance Shaw
body: ![Rule.png](https://community.atlassian.com/t5/image/serverpage/image-id/231716i188BA0C65DEC5114/image-size/large?v=v2&px=999 "Rule.png")