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.