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.
Dear community,
I'm trying to run a Scriptrunner validator's custom script in a certain step (where I review a custom field in all linked issues). The issue is, when I run the below script in console, it works fine and as expected. But when it is triggered in a validator trigger, it "issue.getCustomFieldValue()" always returns null.
The code is as follows (in validator):
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def issueManager = ComponentAccessor.getIssueManager();
def rootCauseCat1 = customFieldManager.getCustomFieldObject("customfield_10422");
List<IssueLink> allOutIssueLink = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId());
for (Iterator<IssueLink> outIterator = allOutIssueLink.iterator(); outIterator.hasNext();) {
IssueLink issueLink = (IssueLink) outIterator.next();
def linkedIssue = issueLink.getDestinationObject();
String issueKey = linkedIssue.getKey();
def convIssue = issueManager.getIssueObject(issueKey);
/*Note: Error happens here. When excuted in validator event, getCustomFieldValue returns 'null', but return actual value executed through console*/
String cRootCauseCat1Value = convIssue.getCustomFieldValue(rootCauseCat1);
if(cRootCauseCat1Value == "Testing"){
throw new InvalidInputException("Alert Message Text");
}
}
I have called "getCustomFieldValue()" from both issue objects "linkedIssue" and "convIssue". But the same results...
First of all, is the validator the best approach? If not, then please guide... If it is, would appreciate your guidance and support on the script used...
Wish you all the Best of Lucks and Regards ... Yours,
H.D.