It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
I am trying to create a scripted field which will populate with a list of users full names from a multi user picker field ("Award Nominees" customfied_21775)
I have tried the following script:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.user.ApplicationUser CustomField multiuserCstFld = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Award Nominees") if (multiuserCstFld == null) return "custom field not found" StringBuilder result = new StringBuilder(); for(ApplicationUser user: (ArrayList) multiuserCstFld.getValue(issue)) result.append(user.getName() + "/") return result.toString().substring(0, result.toString().length() - 1)
but I get the following syntax error:
[Static type checking] - Cannot loop with element of type com.atlassian.jira.user.ApplicationUser with collection of type java.util.ArrayList
I'm at a loss as to what is wrong. I am on JIRA version 7.1.9 and using scriptrunner version 4.3.13
Any help would be greatly appreciated. Thank you!
If you want their full names, you'll want to use the getDisplayName method.
import com.atlassian.jira.component.ComponentAccessor def awardNomineesField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Award Nominees") if (!awardNomineesField) { return null } issue.getCustomFieldValue(awardNomineesField)?.collect{ it.displayName }?.join(" / ")
Try this code
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.user.ApplicationUser CustomField multiuserCstFld = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Award Nominees") if (multiuserCstFld == null) return "custom field not found" StringBuilder result = new StringBuilder(); for(ApplicationUser user: (ArrayList<ApplicationUser>) multiuserCstFld.getValue(issue)) result.append(user.getName() + "/") return result.toString().substring(0, result.toString().length() - 1)
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreHey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.