Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to change an issue's status based on a condition while creating the issue?

Özge K_ September 21, 2021

 

I'd like to specify an issue's "Status" as "Done" on its "Create" transition screen if its "End date" field is filled. I will use this functionality while I'm informing a new issue which had already completed. Can I perform this action by using post functions? I've tried 2 post functions but cannot handle this problem. Its "Status" still seems as "To Do". How can I solve this problem?

Capture2.JPG

Capture.JPG

1 answer

1 vote
John Funk
Community Champion
September 21, 2021

Hi @Özge K_  - Welcome to the Atlassian Community!

You can do that with an Automation for Jira rule that would fire on create of the issue. 

Then add a condition to check if the End Date is not empty.

And if not, then transition the card to Done. 

Özge K_ September 27, 2021

Hi @John Funk , Thanks for your kind greeting at first !

I've been trying to solve this issue as you declared above. but cannot succeed it.

I don't have an idea about the automation part but I found something useful. I added a post function (Fast-track transition an issue [ScriptRunner]). Here it's screenshot:

a.JPG

b.JPG

and my script is :

import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def endDate = customFieldManager.getCustomFieldObjectByName("End Date [Gantt]")
def status = customFieldManager.getCustomFieldObjectByName("Status")
if (issue.getCustomFieldValue(endDate) != null){
issue.setCustomFieldValue(status, "DONE")
}

It still doesn't work. Could you please tell me what my fault is ?

John Funk
Community Champion
September 29, 2021

Sorry, I don't use ScriptRunner, so I do not know what would be wrong with the script. :-(

Here is more information about Automation to get you started:

There are two types of automation:

  • Global: In the Free version, you get 100 executions per product, per month
  • Project: In all versions, you get unlimited executions per month

Automation Basics: https://www.atlassian.com/software/jira/guides/expand-jira/automation

You can do this via global rules to apply to all projects also. You'll need to be a Jira Admin/Site Admin, go to Jira Settings > System > Automation Rules (left-hand menu).

For more on using Automation For Jira see these help pages.

Jira Automation Template Library to help get you started quickly:

https://www.atlassian.com/software/jira/automation-template-library#/labels/all/customLabelId/1453

Suggest an answer

Log in or Sign up to answer