How to set the custom field value of a radio button?

this is my code

def public SupportPlan(MutableIssue issue)
{   
    ComponentManager componentManager = ComponentManager.getInstance();
    customFieldManager = componentManager.getCustomFieldManager();
    IssueManager issueManager = ComponentAccessor.getIssueManager();
    def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
    User currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
    
    CustomField cfSType = customFieldManager.getCustomFieldObjectByName("Support Type");
    def cfSTypeV = issue.getCustomFieldValue(cfSType);
    log.warn("Support Type of the customer: " +cfSTypeV);
    
    CustomField cfmail = customFieldManager.getCustomFieldObjectByName("Customer Email");
    String cfmailV=(String)issue.getCustomFieldValue(cfmail);
    
    //Fetch domain name value
    def domain_name = cfmailV.substring(cfmailV.indexOf("@")+1, cfmailV.lastIndexOf("."));
    log.warn("print domain name" +domain_name);
    JqlClauseBuilder builder = JqlQueryBuilder.newClauseBuilder();
    Query query = builder.customField(cfmail.getIdAsLong()).like(cfmailV).buildQuery();
    SearchProvider searchProvider = ComponentAccessor.getComponentOfType(SearchProvider.class);
    SearchResults searchResults = searchProvider.search(query,currentUser,PagerFilter.getUnlimitedFilter());
    List<Issue> issues = searchResults.getIssues();
        
    for (def allIssues : issues)
    {   
        String cfAIemailv = (String)allIssues.getCustomFieldValue(cfmail);
        String aidomain_name = cfAIemailv.substring(cfAIemailv.indexOf("@")+1, cfAIemailv.lastIndexOf("."));
        log.warn("Print all domain names" +aidomain_name);

          if(domain_name == aidomain_name)
        {
          CustomField cfSupport = customFieldManager.getCustomFieldObjectByName("Support Type");
           allIssues.setCustomFieldValue(cfSupport,cfSTypeV);

        }

    }
}
SupportPlan(issue);

I'm getting following error while setting the value

[onresolve.jira.groovy.GroovyRunner] The script failed : javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.DocumentIssueImpl.setCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.CustomFieldImpl, com.atlassian.jira.issue.customfields.option.LazyLoadedOption) values: [Support Type, Gold]

Possible solutions: getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField)

1 answer

1 accepted

Try this

List<MutableIssue> issues = searchResults.issues.collect {issueManager.getIssueObject(it.id)}

to convert the DocumentIssueImpl object with "normal" MutableIssue objects.

 

Tried your solution. It gives no error,but doesn't set the field value either. Log shows as null value.

Henning Tietgens Community Champion Jan 08, 2014

Oh, yes, you have to update the issue. Either by using the prefered way through IssueService (in which case you have to rewrite your code to use IssueInputParameters for updating the customfield) or by calling issueManager.updateIssue() after setting the customfield (in this case no permissions checks are made, e.g. is the current user allowed to update the issue).

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

839 views 2 9
Read article

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