Hi,
I have a drop down list - To Queue having values (Service Desk, IT- Imaging and so). If i choose service desk, in the assignee field i should get list of users on the Group Service Desk. I tried to use the script below but i am having an error of deprecation comment in the line - userToReassign = userUtil.getUserObject("Service Desk")
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.user.util.UserUtil
import org.apache.log4j.Level
import com.atlassian.jira.component.ComponentAccessor
log.setLevel(Level.DEBUG)
log.debug "Starting postfunction..."
if (issue.isSubTask()) {
log.debug "Issue is subtask, leaving."
return
}
def tr = customFieldManager.getCustomFieldObjectByName ("To team")
def trValue = issue.getCustomFieldValue(tr) as String
def userToReassign = issue.getAssignee()
log.debug "Got assignee ${userToReassign}."
UserUtil userUtil =ComponentAccessor.getUserUtil()
if (trValue == "Service Desk") {
userToReassign = userUtil.getUserObject("Service Desk")
// issue.setResolution(resolutionManager.getResolutionByName("Closed successful"))}
//issue.setAssignee(ComponentManager.instance.userUtil.getUserObject('john_smith')
}
log.debug "Setting user to ${userToReassign}."
issue.setAssignee(userToReassign)
Kindly let me know what is the new code to replace the above.
Thanks
Swarna
Here is refacrored version of your code
import com.atlassian.jira.issue.fields.CustomField
import org.apache.log4j.Level
import com.atlassian.jira.component.ComponentAccessor
log.setLevel(Level.DEBUG)
log.debug "Starting postfunction..."
if (issue.isSubTask()) {
log.debug "Issue is subtask, leaving."
return
}
String userToReassign = issue.getAssigneeId()
log.debug "Got assignee ${userToReassign}."
switch( (String) issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName ("To team"))) {
case "Service Desk":
// issue.setResolution(resolutionManager.getResolutionByName("Closed successful"))}
issue.setAssigneeId (ComponentAccessor.getUserManager ().getUserByName ("john_smith"))
}
log.debug "Setting user to ${userToReassign}."
issue.setAssignee(userToReassign)
Hi Vasiliy,
To Team is a drop down list, i need to choose "Service Desk" which populated all members from "Service Desk" group in the assignee field. In your code where service desk is assigned to Service Desk group.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dave,
I am still having error using the following line
userToReassign = ComponentAccessor.userUtil.getObjectByName("Service Desk")
Thanks
Swarna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
G'day Swarna,
Looking over the docs, that function has been deprecated in favour of getUserByKey(String)
or getUserByName(String)
instead.
Since you probably have a username, you should be able to use the getUserByName method instead. Does this help you move forward with your script? Let me know if it does!
Cheers,
Dave
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dave,
I am still having error using the following line
userToReassign = ComponentAccessor.userUtil.getObjectByName("Service Desk")
Thanks
Swarna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.