Behavior does not actually add the value to the issue, it just selects it

Hello,

I have the following behavior which refers to two custom fields (both are select lists). I want it to set a value to custom field b when something from A is selected:

import com.atlassian.jira.component.ComponentAccessor


def customFieldManager = ComponentAccessor.getCustomFieldManager()


def reqproj = getFieldByName("Requesting Project")
def segment = getFieldByName("Segment")


def reqprojVal = reqproj.getValue()

// If Select List 1 is set to option A then set selectList2 to option B
if(reqprojVal.toString().contains("A88")){
// Set the value to the ID of option B
segment.setFormValue(26744)
}

else if (reqprojVal.toString().contains("B")) { segment.setFormValue(26744)}

else if (reqprojVal.toString().contains("C")) { segment.setFormValue(26745)}

 

Although it does not throw an error, it seems that it only selects the value on an issue, but not also actually adds it. To be more clear: if I open an issue, on the view screen I do not see the value for Segment, but if I edit the issue, I see that the proper option is selected.

Please help.

Thank you.

1 answer

1 accepted

Disregard the question, I applied the behavior to the second custom field instead of the first one.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

243 views 1 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