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.

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Sarika Dalal
Community Champion
December 7, 2021

@Berry Kersten I think the approach you suggested using script runner is the best way to do that.

Script runner post function for send mail is already present which will give you option to map custom field in the body/Subject and you can add attachment as well from here.

 

Regards,

Sarika Dalal

Berry Kersten
Contributor
December 10, 2021

Hi @Sarika Dalal Great. Thanks!

One more question. Is is also possible to store the sent custom email in a comment? Did not see that functionality in in the documentation.

 

Cheers, Berry.

Sarika Dalal
Community Champion
December 12, 2021

@Berry Kersten , Yes You can do that via Custom script.

TAGS
AUG Leaders

Atlassian Community Events