Forums

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

get value from selected customfield

Olivera Tancheva
January 16, 2019

I am trying to compare a value from a multiselect customfield. i did the following code:

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;
import com.atlassian.jira.user.util.UserManager;
import com.atlassian.jira.issue.MutableIssue
import com.onresolve.scriptrunner.runner.util.UserMessageUtil

def issueManager = ComponentAccessor.getIssueManager();
def userManager = ComponentAccessor.getUserManager();
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def cField = customFieldManager.getCustomFieldObject("customfield_12032");
def cFieldValue = issue.getCustomFieldValue(cField);

if (cFieldValue.toString() == "Business Trips")
{
    UserMessageUtil.error('Please select project.')
}

 

But the code only works when I put cFieldValue.toString() == "None". I can't seem to figure out why it doesn't work for the other options.

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Amir Katz (Outseer)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
December 8, 2021

I've submitted a ticket to Atlassian support, ping me in private if you want to view it:

https://getsupport.atlassian.com/servicedesk/customer/portal/48/PCS-69271

0 votes
Tessa Tuteleers
Community Champion
December 1, 2021

Hi @Amir Katz (Outseer) ,

Odd!
Which string are you trying to add to the field help? (are you using special characters?)

- Tessa

Amir Katz (Outseer)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
December 1, 2021

no special characters.

Project settings -> Request types -> <pick request type> -> Request form -> Visible fields -> hover to field, click in 'Field help', type text, click Update --> text disappears.

 

I have no scripting-related extensions in my browser (Chrome latest).

TAGS
AUG Leaders

Atlassian Community Events