Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Apps & Integrations

How we use Jira Service Management for our recruitment process! - Part 2

It is never about setting up a process and being done with it. Rather, the focus should always be on optimizing it for the best outcomes. Thus, we didn’t stop at setting up JSM for our recruitment pr...

179 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you