getCustomFieldValue return null in validator, but runs correctly in console

Hamad Dheyab
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 7, 2021

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