Hi There!
I'm searching for a solution that provides me an opportunity to add the user from Custom Field to specific JIRA Group by the post-function workflow.
Thank You in advance,
You need to read the value from the custom field and do something like this. <read user from custom field> depends on the type of your custom field
import com.atlassian.jira.component.ComponentAccessor def groupManager = ComponentAccessor.getGroupManager() def user = <read user from custom field>
def group = groupManager.getGroup("Group1") groupManager.addUserToGroup(user,group)
@Alexey Matveev wow, thank you for prompt answer!
On more question: could you provide a more detailed example of this row:
def user = <read user from custom field>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is your custom field type for the user?
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.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
def groupManager = ComponentAccessor.getGroupManager()
def user = (ApplicationUser) ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("test_mav_user_picker").getValue(issue)
def group = groupManager.getGroup("group1")
groupManager.addUserToGroup(user,group)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I'm using script runner and I need to remove user from group. Can you write script like this please.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I need the same script for getting users to group by using Multi-User picker field. help in this
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Perhaps someone can help me with following, I'm trying to create a transition post-function that adds user to a group (from a user picker custom field). However, when running below script...
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
def groupManager = ComponentAccessor.getGroupManager()
def user = (ApplicationUser) ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Field Name").getValue(issue)
def group = groupManager.getGroup("Group1")
groupManager.addUserToGroup(user,group)
...I get this error
019-10-24 22:36:14,574 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2019-10-24 22:36:14,575 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: ISSUE-66, actionId: 11, file: <inline script> org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[user@user.com)]' with class 'java.util.ArrayList' to class 'com.atlassian.jira.user.ApplicationUser' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.atlassian.jira.user.ApplicationUser(com.atlassian.jira.user.DelegatingApplicationUser) at Script74.run(Script74.groovy:6)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all,
I need the same script for getting users to group by using Multi-User picker field. Can anyone help in this, as its an urgent requirement.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
def groupManager = ComponentAccessor.getGroupManager()
def user = (ApplicationUser) ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("test_mav_user_picker").getValue(issue)
def group = groupManager.getGroup("group1")
groupManager.addUserToGroup(user,group)
above mentioned script is working very well for adding single user in group. The requirement is to add multiple users to the group by having multi user picker custom field.
Please help me in this script..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
do you get the script for getting users to group by using Multi-User picker field ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you please suggest me whats I am doing here in below groovy script.
I am attempting to add users listed in below user list to a respective group Group1.
I am using Script Console to perform this task.
import com.atlassian.jira.component.ComponentAccessor
def userManager = ComponentAccessor.getUserManager()
def groupManager = ComponentAccessor.getGroupManager()
def user = ["Chandrakanta Swain", "Ikramirshad Khan", "Mohammed Shaheen", "Nagasudheerkumar Kappala"];
def group = groupManager.getGroup("Group1")
userManager.getAllUsers().each {
user -> groupManager.addUserToGroup(user,group)
}
2019-03-31 13:49:18,240 WARN [common.UserScriptEndpoint]: Script console script failed: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script57.groovy: 10: expecting '}', found '-' @ line 10, column 6. user -> groupManager.addUserToGroup(user,group) ^ 1 error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
user -> groupManager.addUserToGroup(user,group
Here you have an error on which swears in the logs
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.