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,555,439
Community Members
 
Community Events
184
Community Groups

getCustomFieldValue return null in validator, but runs correctly in console

Edited

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.

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events