Behaviours plugin - set field value based on multiple conditions

Hi,

I'm pretty new to Groovy programming and right now I'm evaluating the possibility of changing field values based on conditions. For those of you familiar with Groovy or Javascript this hopefully should be a piece of cake...

What I'm trying to achieve is the following:

An issue is in the status of "QA". If I update my custom field (in edit mode "target QA due", another field has to be updated aswell, the "current milestone due". I'm only reporting on "current milestone due" in order to keep my list view kind of clean.

Currently I have implemented a post function copying the "target QA due" value to my "current milestone due" field on transitioning to the "QA" status. That works well. The only problem is if I change my planning (target) value while the issue is in the QA status there is no post-function updating the other field.

I hope you guys understand my problem?

If it's possible I'd need sth like this (ignore the syntax:-):

IF (status="QA") {value.currentMilestoneDue = value.target QA due}

ELSE IF (status="review") {value.currentMilestoneDue = value.reviewDue}

ELSE IF....

Any help is really being appreciated!!

Cheers Christian

2 answers

1 accepted

1 votes
Mizan Community Champion Jul 03, 2012

Hi Christian ,

If the status is QA and user edits the issue and sets the value of "target QA due " then this value should be copied or set to the other field "current milestone due" right ?

This can be achieved using Behaviours plugin , You will have to write a server side script on "target QA due " which will copy or set the value of "target QA due" to "current milestone due" when status is QA .

You should go through the document first , the examples are really helpful

I guess I've sorted it out with the help of Jamies comments:

https://studio.plugins.atlassian.com/browse/JBHV-134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#issue-tabs

import com.atlassian.jira.ComponentManager

def issueId = formContents["id"]
def issue = ComponentManager.getInstance().getIssueManager().getIssueObject(issueId as Long)
def issueStatus = issue?.statusObject?.name

FormField formStoryline = getFieldByName("Plandatum (Storyline)")
FormField formMilestonePlan = getFieldByName("Plandatum (aktueller Meilenstein)")


//if(formStatus.getFormValue() == "Abstimmung Storyline"){
if(issueStatus == "Abstimmung Storyline"){
formMilestonePlan.setFormValue(formStoryline.getFormValue())
}

Mizan Community Champion Jul 04, 2012

Thanks for sharing :)

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,755 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot