Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,362,519
Community Members
 
Community Events
168
Community Groups

Problem with groovy and postfunction

Hi,

we have a groovy, that do not work from several weeks:

import com.atlassian.jira.issue.fields.CustomField;

import com.atlassian.jira.issue.CustomFieldManager;

import com.atlassian.jira.component.ComponentAccessor;

import com.atlassian.jira.user.util.UserManager;

import com.atlassian.jira.user.ApplicationUser;

import com.atlassian.jira.user.ApplicationUser;

import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;

import com.atlassian.jira.issue.util.IssueChangeHolder;

import com.atlassian.jira.issue.ModifiedValue;

import com.atlassian.jira.issue.customfields.manager.OptionsManager;

 

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();

IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();

 

def userManager = ComponentAccessor.getUserManager();

def issueManager = ComponentAccessor.getIssueManager();

 

def jobInterviewerICSD = customFieldManager.getCustomFieldObjectByName("Job Interviewer I CSD");

def jobInterviewerIPBS = customFieldManager.getCustomFieldObjectByName("Job Interviewer I PBS");

 

CustomField privilegesField = customFieldManager.getCustomFieldObjectByName("Access privileges");

 

if(jobInterviewerICSD != null){

               ModifiedValue newPrivilegesField = new ModifiedValue(issue.getCustomFieldValue(privilegesField), jobInterviewerICSD);

               privilegesField.updateValue(null, issue, newPrivilegesField, new DefaultIssueChangeHolder());

               return privilegesField;

}

 

if(jobInterviewerIPBS != null){

               ModifiedValue newPrivilegesField = new ModifiedValue(issue.getCustomFieldValue(privilegesField), jobInterviewerIPBS);

               privilegesField.updateValue(null, issue, newPrivilegesField, new DefaultIssueChangeHolder());

               return privilegesField;

}

 

The postfunction error shows:

 

 

2018-06-15 11:46:45,266 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************

2018-06-15 11:46:45,267 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: REC-19463, actionId: 891, file: /var/atlassian/application-data/jira/scripts/GroovyScripts/recruitnsc/scripts/set_access_privileges.groovy

java.lang.ClassCastException: com.atlassian.jira.issue.fields.ImmutableCustomField cannot be cast to java.util.Collection

      at com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType.createValue(AbstractMultiCFType.java:39)

      at com.atlassian.jira.issue.fields.ImmutableCustomField.createValue(ImmutableCustomField.java:693)

      at com.atlassian.jira.issue.fields.ImmutableCustomField.updateValue(ImmutableCustomField.java:410)

      at com.atlassian.jira.issue.fields.ImmutableCustomField.updateValue(ImmutableCustomField.java:396)

      at com.atlassian.jira.issue.fields.OrderableField$updateValue.call(Unknown Source)

      at set_access_privileges.run(set_access_privileges.groovy:25

Do you see any possible errors?

 

Thank you

1 answer

There are several incorrect or improvable things in that script. What are you trying to do here?

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events