Community Announcements have moved! To stay up to date, please join the new Community Announcements group today. Learn more
×Hi,
I am trying to set the 'Team' custom field value whenever an assignee is selected or changed according to a csv file which has the mapping for the 'assignee - respective team'.
In the ScriptRunner, I'm setting up a custom listener for 'Issue Assigned' event and writing the following script to check the logic: if X is the assignee, set Y as the 'Team' custom field value.
I'm getting an error on the script console for "ResponsibleTeam_field.updateValue(..)" statement.
I'm new to this and any help would be really appreciated.
import org.apache.commons.csv.CSVRecord;
import org.apache.commons.csv.CSVFormat;
import java.nio.file.Paths;
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.issue.MutableIssue;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.security.groups.GroupManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.customfields.view.CustomFieldParams;
import com.atlassian.jira.issue.fields.config.FieldConfig;
Iterable<CSVRecord> reader = CSVFormat.RFC4180.withFirstRecordAsHeader().parse( new FileReader( "Path where the csv is stored" ) );
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
GroupManager groupManager = ComponentAccessor.getGroupManager();
def assigneeJira = Issue.getAssignee();
if (assigneeJira == 'null' || assigneeJira == null || assigneeJira==''){
assigneeJira ='';
}
String ResponsibleTeamJira = '';
CustomField ResponsibleTeam_field = customFieldManager.getCustomFieldObject('customfield_10120');
if (ResponsibleTeam_field){
ResponsibleTeamJira = Issue.getCustomFieldValue(ResponsibleTeam_field );
if (ResponsibleTeamJira == null){
ResponsibleTeamJira = '';
}
}
for (CSVRecord line : reader) {
String assigneeCsv = line.get("Assignee");
String ResponsibleTeamCsv= line.get("Responsible team");
if (assigneeJira.equals(assigneeCsv)
) {
Group Responsible_Team = groupManager.getGroup(ResponsibleTeamCsv);
List<Group> Responsible_Team_List = new ArrayList<Group>();
Responsible_Team_List.add(Responsible_Team);
def changeHolder = new DefaultIssueChangeHolder();
ResponsibleTeam_field.updateValue(null, Issue, new ModifiedValue(Issue.getCustomFieldValue(ResponsibleTeam_field), Responsible_Team_List ),changeHolder);
}
}
What is the error?
Hi Alexey,
This is the exact error that I'm getting:
[Static type checking] Cannot find matching method
com.atlassian.jira.issues.fields.CustomField#updateValue(<unknown parameter type>,
java.lang.Class <com.atlassian.jira.issue.Issue>,com.atlassian.jira.issue.ModifiedValue, com.atlassian.jira.issue.util.DefaultIssueChangeHolder). Please check if the declared type is right and if the method exists.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is a static compilation error. Try to execute the code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried changing the assignee but it did not work as expected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What was the error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unlock your potential and learn how to use Jira Product Discovery to your advantage. You’ll have the expertise to revolutionize ideas and insights, roadmapping, engage and align teams and stakeholders, and deliver the best solutions—faster. Enroll today!
Start Learning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.