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.
Using Script Runner and Behaviors
I am looking to pull all issue id's for a specific project and then for each issue, compare one of its custom field values to a string. This string will be whatever the user entered into that custom field for that specific issue on the form (CR Number). If the custom field value (from all the other issues) is equal to that string (what was entered), then I need to raise an error stating that the value needs to be changed (no duplicates of "CR Number" are allowed)
What I have so far is I am able to get the list of all issues from my project and I believe all Issue objects have their field values in the said object.
So now I want to do my comparison:
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor;
def issueMgr = ComponentAccessor.getIssueManager()
def issues = issueMgr.getIssueObjects(issueMgr.getIssueIdsForProject(10000))
//Here - how do I get what was entered into the custom field and compare it to all the CR NUMBER fields of the returned Issue item list (issues)
def input = getFieldById("customfield_10302")
def val = input.getValue() as String
for (int i = 0; i < issues.size(); i++){
if(issues[i].getCustomFieldValue(getFieldById("customfield_10619").equals(val))){
//raise an error here and user must try a different value
}
}
Hmm what you are trying to do has a lot of performance penalty, imagine looping 20,000 issues just to compare the values every time the Custom Field changes.
What I will do is fix the custom field value of the existing tickets by doing a bulk update.
And in the behavior I will then properly filter the value of what the user will input.
That way you future proof any data that will be written in your instance.
Thanks for your response, however I am not able to understand what you are suggesting. Can you please also include code snippets or pseudo code?
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.