Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,554,508
Community Members
 
Community Events
184
Community Groups

GroovyScript: Get User located in Custom Field within an issue.

Edited

Hi Everyone!

     In my organization, our Jira setup has a customField_12000 which is pointed to an object labeled "Affected Objects", there can be multiple Affected Objects", Within these objects is a Contact(s) field with multiple users inside. Does anyone know an easy way to fill this value?

Taking a step back, the goal is really to target an "Affected Object" by itself and not specifically from a linked issue, then to show who is the primary contact for that object through a rest call if possible.

It seems alot of examples help me pull the Affected Object itself but not the contact within?

I messed with the GroovyScript to see if I could get it to load anything and I was able to successfully reflect the name of the affectedobject within the field but not the contact located within that specific object.

Thanks for any Pointers!!

[My failed attempts]

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
//ComponentAccessor.getCustomFieldManager().getCustomFieldObject(12000); = "Affected Object(s)"
def value = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject(12000)); // Change ID to the correct one

CustomField myCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(12000)
def objectBean = myCF.getValue(issue)[0]

/* If an insight custom field has an object called "Microsoft" it will fail */
if (value != null && "Microsoft".equals(value[0].getName())) {
return "This is not a valid vendor!";
}
//return value[0].getAt(0).name
return objectFacade.loadObjectAttributeBean(value[0].getId(), 12000).getObjectAttributeValueBeans()[0].getValue()
return value[0].toString()
return value[0].getId()
return value[0].getLabel()
return value[0].getClass()
return value[0].getName()

 

The code above helps return some minor details of the affect object selected at index [0] but what am I missing to get the underlaying attribute?

1 answer

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events