You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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
There are several incorrect or improvable things in that script. What are you trying to do here?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.