Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can I restrict cloning?

Eduard Diez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 23, 2021

Hello community

Can I restrict cloning, (admins only) on jira server issues?

If is possible can you tell me how can I'll do?

Thank you

2 answers

0 votes
Alexis Bueno
June 15, 2015

Hey Jamie,

I am still unable to get this script to generate subtasks for my customfield of users.

I put this as a condition on a script to create subtasks, I also tried it as the Additional issue actions. Neither seems to work.

 

Here is the script I have, any suggestions?

 

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.crowd.embedded.api.Group;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.config.SubTaskManager
import org.ofbiz.core.entity.GenericValue
import com.atlassian.jira.user.UserUtils
import com.atlassian.jira.user.util.UserManager
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.security.util.GroupSelectorUtils 
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
def issueFactory = componentManager.getIssueFactory()
def issueManager = componentManager.getIssueManager()
def indexManager = componentManager.getIndexManager()
def groupCf = customFieldManager.getCustomFieldObjectByName("Reviewers") // name of group CF
def UserList = []
User currentUserObj = UserUtils.getUser(currentUser)
GroupSelectorUtils util = (GroupSelectorUtils) ComponentManager.getInstance().getContainer().getComponentInstanceOfType(GroupSelectorUtils.class) 
Group group = issue.getCustomFieldValue(groupCf) as Group
//issue.getCustomFieldValue(groupCf).each {Object group ->
if (group) {
//group.getUsers().each {String user ->
//Group groupObj = util.getGroups((String) group)
//groupObj.getAllUsersInGroup().each {String user ->
    def groupManager = ComponentAccessor.getGroupManager()
        groupManager.getUsersInGroup(group).each {String user ->
    if(!UserList.contains(user) && user != currentUser) {
        
        MutableIssue newIssue = issueFactory.getIssue()
        newIssue.summary = "Doc ERB Assessment for $user"
        newIssue.issueTypeId = '12600'
        newIssue.project = issue.project
        newIssue.assigneeId = user
        Map<String,Object> newIssueParams = ["issue":newIssue] as Map<String,Object>
        def currentUser = componentManager.getJiraAuthenticationContext().getUser()
        GenericValue newIssueGv = issueManager.createIssue(currentUser, newIssueParams)
        indexManager.reIndex(newIssueGv);
        SubTaskManager subTaskManager = componentManager.getSubTaskManager()
        subTaskManager.createSubTaskIssueLink(issue, newIssue, componentManager.getJiraAuthenticationContext().getUser())
        
        UserList.add(user)
         }
       }
    }
 }
0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 11, 2015

There's no method getUsers on com.atlassian.crowd.embedded.api.Group

Use for eg: com.atlassian.jira.user.util.UserUtil#getAllUsersInGroups

 

Suggest an answer

Log in or Sign up to answer