Hi,
I working with transition which creating custom projects with ScriptRunner. I trying to get username from Multi User Picker and add this people to role "Administrators". I have problem with passing datas. My code:
def Key = customFieldManager.getCustomFieldObject("customfield_17306")
def KeyValue = issue.getCustomFieldValue(Key)
def project = projectManager.getProjectObjByKey("$KeyValue")
def projectRole = projectRoleManager.getProjectRole("Administrators")
def actors = ["174373","email-tasks"]
projectRoleService.addActorsToProjectRole(actors,
projectRole,
project,
ProjectRoleActor.USER_ROLE_ACTOR_TYPE,
errorCollection)
and this working, beacuse actors are in "". When i trying get values from custom fields, like this:
def Admin = customFieldManager.getCustomFieldObject("customfield_17303")
def AdminValue = issue.getCustomFieldValue(Admin).username
I have this this format: [abc, test123, test], so without "". I must pass this to actors variable with "". Do you have idea what i can take data with "" or add this later? For all characters in username's.
You've not accounted for the field being a multi-user picker. When you get a value from a multiple-entry field like this, the value returned is an array of content objects. It may be an empty array (field is empty), or only have one entry, but it's still an array.
So, you'll want to iterate over that, and work out which user(s) to add from the field. Start with something like:
def cfValue = issue.getCustomFieldValue(multi-user-picker-field)
cfValue.each { ApplicationUser userToAdd ->
actors.add(userToAdd)
}
Good idea, but i have problem with method...
but actors in each AdminValue? I don't understand... how you define "actors"?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I took it from your code in the question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
my requirement is need to send the notification mail to all users available in 1,2 & 3 user picker fields.Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's hard to read unformatted code. I understand what you're trying to do, but could you tell us where it is going wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.