I have a web panel created through scriptrunner that I want displayed only if a customfield has been populated with a value.
I've been trying to use condition to no avail
Tried setting condition in script to :
cfValues['Priority Score'] > 0
But I get a cfValues is undeclared in the code box and regardless of value the web panel doesn't show.
How do I properly reference the custom field "priority score" in a condition
Hi @tonyrath
I'm not Script Runner expert, but let me try to help.
Where do you find or set cfValues?
I think you should write a script to get the custom field value and return true if the field has value as below.
Please be aware that I did not try the code, I just write it here.
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager()
CustomField cf = customFieldManager.getCustomFieldObjectByName('Priority Score')
return null != issue.getCustomFieldValue(cf)
Thanks Tuncay, that got me on the right path
This is what ended up working :
import com.atlassian.jira.component.ComponentAccessor;
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;
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_10504")
def cFieldValue = issue.getCustomFieldValue(cField)
cFieldValue != null
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm glad to hear that.
Please accept the answer so that other community members who has similar issues would see the correct path.
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.