Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

if reporter is member of a group get a custom field

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")

 

3 answers

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

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")
}

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

109 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you