How I can get a customfield value

Hi all,

This is a simplified version of my workflow:

workflow.jpg

My problem is how can I do, in the transition screen 2,  for manage chk 2 according chk1. I tried with behaviours (maybe it is not the best way) with this code but I can not recover the value of chk 1:

 

def f1 = getFieldById("customfield_14613")
def f2 = getFieldById("customfield_14617")
def f1val = f1.getValue()

f2.setFormValue(false)
f2.setHidden(false)

if(!f1val){
 f2.setFormValue(true)
 f2.setHidden(true)
}

If someone could help me or give me some clues

Thanks

 

2 answers

This widget could not be displayed.

Hey Eric,

I had this similar question and Jamie gave a suggestion as posted in this thread

 

Good Luck

Chander

Ok Chander, thanks for this link, I will watch.
I hope this help me

thanks again :)

 

This widget could not be displayed.

Ok, I had found the solution, if this can help someone

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue

// Get the current issue
IssueManager issueManager = ComponentAccessor.getIssueManager()
def issueId = formContents["id"]
def currentIssue = ComponentAccessor.getIssueManager().getIssueObject(issueId as Long)

// Get the value of "Spec Necessary" and "Reference Manual Changes Necessary" customField
def customField = ComponentAccessor.getCustomFieldManager()
def fSpecNecessary = customField.getCustomFieldObject("customfield_14613")
def valSpecNecessary = fSpecNecessary.getValue(currentIssue)

// Initialize "Spec Reviewed" and "Reference Manual Updated" customField
def fSpecReviewed = getFieldByName("Spec Reviewed")

// If valSpecNecessary == null, we set the "Spec Reviewed" checkbox on ReadOnly (gray out) and set value to "true" for pass the validator
if(valSpecNecessary == null){
fSpecReviewed.setFormValue(true)
fSpecReviewed.setHidden(true)
}

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

139 views 2 0
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