Hello All,
In our project, there is a Group Picker(single group) custom field. In that Custom field, there are 3 user groups(R1, R2, R3).
If I select an R1 group while creating the issue, R1 user group should get notifications that issue is created.
Any help?
Thanks,
Manikanta
Hi
Here is the final solution for this ticket.
You have to create an "custom event" for this event select the Template "Issue Update" and add it .
In the project notification scheme in that particular custom event that you created add your "Group Picker " Filed and then
> Admin Settings ---> Add-ons---> left hand pannel "Script Listener" ---> Add Item select "Fire an event when the condition is true"
> Select the "Target Project " ---> Events select "Issue Update and Custom Event that you created" ---> Condition add the below Script ---> Event select the Custom Event that you created.
import com.atlassian.crowd.embedded.impl.ImmutableGroup
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.customFieldManager
def issue = event.issue
def customField = customFieldManager.getCustomFieldObject(10801 as Long) // change to your field id
log.warn("Custom field: " + customField)
def customFieldValues = issue.getCustomFieldValue(customField) as ArrayList<ImmutableGroup>
log.warn("Custom field value list: " + customFieldValues)
log.warn("First Custom field value: " + customFieldValues?.get(0)?.name)
log.warn("Result: " + customFieldValues?.get(0)?.name == "X") // instead of X give the name of your group you want
return customFieldValues?.get(0)?.name == "X"
in the above script if you see any static error's just avoid it.
How this script works means ??
When you pick the group name that you have mention in the script in the "Group picker" filed
now when you edit the issue while that field contains that particular group that group users will receive the notification until you change the Group to another group
once you change the group nobody will not recieve any notifications.
Hope its helps
Thanks,
Kumar
Hi @Bunty
Adding the group picker to the notification scheme should satisfy your request as Alexey has suggested.
However I would refrain from doing this as I will not have any control on how many users get added to the group and if my group gets large as the instance grows it can build my mail queue depending on how many issues get created and how many users are in the group. Its difficult to keep track of this if you have a couple of Jira admins to manage your instance.
How we manage such requests in our instance is, we have a validator to check if the mentioned group size is not greater than 100 and a post function to add the users of this group as watchers.
You can use Script Runner Plugin to get your validator and PF scripted.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vinu I do also have same similar task could you please provide the Script for this to achieve for me I need only when user select particular group in the field while creating the ticket only that group members has to get notification
if i select other groups in that field they don't want notification.
example:
I'm creating a ticket I selected "R1" in the Group Picker field that group members has to get notification . if I select "R2 or R3" for those groups don't required notification
can you please provide the script to achieve this
Thank,
Kumar
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.
Hi @Vinu I'm getting error when i have tried that script can you tell me the 1st 3 lines of script its showing an error on 1st line
thanks,
kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kumar
You need to import component accessor and group library files.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vinu this is how i have made changes to the script as I need can you please look at it once
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.crowd.embedded.api.Group
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customfield = customFieldManager.getCustomFieldObject('customfield_10801')
if (customfield == Group)
{
return
}
def groupName = issue.getCustomFieldValue(customfield) as String
if (groupName == R1)
{
return
}
def groupManager = ComponentAccessor.getGroupManager()
def watcherManager = ComponentAccessor.getWatcherManager()
def watchers = groupManager.getUsersInGroup(groupName)
if (watchers.size() > 100)
{
return
}
watchers.each {
watcherManager.startWatching(it, issue)
}
is it ok please let me know
Thanks,
kumar
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.
Hi @Vinu Thanks for your response the above script that you have provided not working so I have tried this script with Behaviors plugin
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.fields.CustomField def customFieldManager = ComponentAccessor.customFieldManager def customField = customFieldManager.getCustomFieldObjectsByName("customfield_10801").first() def customFieldValue = issue.getCustomFieldValue(customField) return customFieldValue == "X"
>Go to Admin Settings drop-down menu > Add-ons > Behaviours.
>Under Add Behaviour, give a Name
>After adding the new Behaviour, click on Fields
>In the "Add Field" search and select "Customfield" Click Add.
>Click Add "Server-side Script". I added that Script.
>Return to Behaviours.
> click Add Mapping I have mapped to "project and Issuetypes".
I followed these steps and I have add that group field in notification Scheme
The only wrong thing about this script is when the ticket is created with "R2 "group and after created If I changed the Group field with "R1" group the "R1" group Getting notifications which is Good thing its working.
and again if I change the group Field from "R1" to "R3" still "R1" group getting notifications. which I dont want
Can you please help me with the above script
Thanks,
Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Go to project settings -> notifications and add this group picker for the Issue Created event.
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.