So I'm trying to create a workflow that allows us to set who the approvers are in a group so that it allows each group to raise a ticket which will notify their approver(s) which can then approve before it comes through to our team.
For example:
Customer A -> User 1, User 2, User 3
Customer B -> User 4, User 5
Customer A's approver is User 2 and Customer B's approver is User 5
If user 1 raises a ticket it should notify User 2 and if User 4 raises a ticket it should notify user 5.
This can be done with the multi user picker and making sure it only lists users in their organisation but what's to stop User 1 from making User 3 the approver who could be sitting next to them in their office which would mean the person who actually does the approvals (User 2) wouldn't know about it.
I thought about creating a separate project per customer so we can set the approvers in the request type fields but that is going to be a nightmare to maintain with duplication everywhere
There must be a way of handling this surely?
So here's the basic of our post-script that sets the approvers field based in our case Field "office"
import
com.atlassian.jira.issue.MutableIssue
import
com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import
com.atlassian.jira.component.ComponentAccessor
import
com.atlassian.jira.issue.ModifiedValue
/**
* Script that Set Approvers depending on the custom field : Office
*/
def customFieldname =
"Office"
//Name of the custom field to get the value from
def userPickerApprovers =
"Approvers"
//User Picker Field that will be populated with all users from the selected group in the groupAppvoers field
Map groupsApprovers = [
"Boston"
:
"NA Client Services Managers"
,
"London"
:
"UK Client Service Managers"
,
"Sydney"
:
"AU CS and Account Managers")
//Map of the [City:Approvers Group for that City]
MutableIssue issue = issue as MutableIssue
def cfManager = ComponentAccessor.getCustomFieldManager()
def myFieldCf = cfManager.getCustomFieldObjectsByName(customFieldname)?.first()
def fieldValue = issue.getCustomFieldValue(myFieldCf)
if
(groupsApprovers.keySet().contains(fieldValue.toString())) {
def groupManager = ComponentAccessor.groupManager
def customFieldManager = ComponentAccessor.customFieldManager
def groupApprovers = groupsApprovers[fieldValue.toString()]
def group = groupManager.getGroup(groupApprovers)
if
(group) {
def users = groupManager.getDirectUsersInGroup(group)
users = users - issue.reporter
def approversField = customFieldManager.getCustomFieldObjectsByName(userPickerApprovers)?.first()
def changeHolder =
new
DefaultIssueChangeHolder()
approversField.updateValue(
null
,issue,
new
ModifiedValue(
null
,users), changeHolder)
}
else
{
log.warn(
"Group ${groupApprovers} not found for issue ${issue.key}"
)
}
}
Apologies for the really ugly formatting...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Julian,
Although this may not work for you, we use scriptrunner to set the Approvers group on creation. So we look at fields (in our case their office) and then use a script to set the Approvers group. THe key for us is in the script we remove the reporter from that list of approvers as we had to stop reporters from approving their own requests.
If you want more info. let me know.
Susan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Susan,
I'd not really looked to much in depth at script runner but it seems like it could do what we're looking for. It sounds like what you have is similar to us but instead of office it's based on the customer/group.
If you'd be willing to point me the right direction with a script to try I'd really appreciate it!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Julian,
There is a way to configure it, that it's better and easier, than create two projects.
You can use Issue Security, to set different levels of access, based on users.
I'm sending you the below documentation, to check if this can help you and in case you need further help, you can return to me.
https://confluence.atlassian.com/adminjiracloud/configuring-issue-level-security-776636711.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So if I'm getting this right with issue security, I could create a security level that allows only User 2 and us to see the ticket once it's made? Wouldn't that prevent User 1 from seeing the ticket they have made?
I expect that I would have to make an Issue Security policy per group to define which users can see the tickets?
I'm not sure how setting the ticket security would prevent User 1 from setting User 3 as their approver, it would only hide the ticket from User 1 and 3? which then would become a manual process to cleanup tickets that have been assigned to an invalid approver.
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.