You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hello ,
I need your help with Groovy please !
I have the following scenario :
" if reporter is member of group "JIRA_VIP" , then get custom field" Category " as VIP "
to get the custom field , I use the postfunction to set the field value function in a transition (using nFeed ) .
I have tried this code but without success !
1 ) ------------------------------------------------------
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.ApplicationUser
currentUser == issue.reporter
def groupManager = ComponentAccessor.getGroupManager()
if (groupManager.isUserInGroup(issue.reporter?.name, 'JIRA_VIP'))
getCustomFieldValue("customfield_11203")
2) ----------------------------------------------------------
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
def groupManager = ComponentAccessor.getGroupManager()
groupManager.isUserInGroup(issue.reporter?.name, 'JIRA_VIP')
3) -----------------------------------------------------------------
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.ApplicationUser
def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Category")
def value = issue.getCustomFieldValue(field)
def groupManager = ComponentAccessor.getGroupManager()
if (groupManager.isUserInGroup(issue.reporter?.name, 'JIRA_VIP'))
getCustomFieldValue("customfield_11203")
Hello I found a solution for this. May be you can use this script:
"
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def userManager = ComponentAccessor.getUserManager();
def groupManager = ComponentAccessor.getGroupManager()
if(groupManager.isUserInGroup(issue.getReporter(), 'JIRA_VIP'))
{
def cField = customFieldManager.getCustomFieldObject("BBB")
def cFieldValue = issue.getCustomFieldValue(cField)
issue.setFieldValue("AAA",cFieldValue);
} elseif (groupManager.isUserInGroup(issue.getReporter(), 'Normal User'))
{
def cField = customFieldManager.getCustomFieldObject("CCC")
def cFieldValue = issue.getCustomFieldValue(cField)
issue.setFieldValue("AAA",cFieldValue);
.....
"
But first create a customfields like ;
AAA -> Category = ( VIP, Normal User, Vendor etc.)
BBB ->Category1 = VIP
CCC -> Category2 = Normal User
and set this fields hidden in the request type; You can show the field AAA to seen from everyone.
Run your script above; if user in VIP group get customfield number Category1 and parse it to general Category customfield.
if user in Normal User group get customfield number Category2 and parse it to general Category custom field.
Hello I have a same problem with your issue.
I have set a custom field at the request type fields. And the field is hidden,
Every request type has a hidden help desk group.
I want to make a chooser ; If current reporter "user" opens a ticket my groovy script will find which group the user belongs to. And set the proper help desk group automatically.
But I am confuced. How to this?
Here is my script
import com.atlassian.jira.component.ComponentAccessor
def groupDGP = ComponentAccessor.groupManager.getGroup("33-Doğal Gaz İşletme ve Piyasa İşlemleri Bölge Müdürlüğü")
if(ComponentAccessor.groupManager.getUserNamesInGroup(groupDGP).contains(currentUser)){
issue.get("customfield_10228")==issue.get("customfield_10503")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey,
Did you manage with this. I am trying to do the same thing... if a user is a member of a VIP group, switch the VIP button on.
Dan
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.