groovy.lang.MissingPropertyException: No such property: customField

Ilya Sklyar
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!
July 2, 2014

I run this script:

import com.atlassian.jira.ComponentManager; 

import com.atlassian.jira.issue.IssueManager; 

import com.atlassian.jira.issue.Issue;

import com.atlassian.jira.issue.CustomFieldManager; 

import com.atlassian.jira.issue.fields.CustomField;

import com.opensymphony.workflow.InvalidInputException

import com.atlassian.jira.issue.IssueManager;



CustomField number = customField.getCustomFieldObject(10005);

def num = issue.getCustomFieldValue(number);

if (num>3) {

    invalidInputException = new InvalidInputException("Too many resolutions")

}

but all I get is this exception:

javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: customField for class: Script19
 
What seems to be the problem here?

2 answers

1 vote
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2014

It's telling what the problem is, you're calling a method on *customfield* which you have not defined.

Use:

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObject(12345)
def num = issue.getCustomFieldValue(cf)

Gnanasakthi C
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!
August 21, 2018

Dear, Am using below script and facing the issue. Please assist..

 

import jxl.*;
import java.io.*;

def testdatafile= "F:\\TestData.xls"; 
log.info(testdatafile)

Workbook work= Workbook.getWorkbook(new File(testdatafile))
Sheet sheet1=work.getSheet("Sheet1")

def Base= (sheet1.getCell(0,0).getContents())
def Accoount= (sheet1.getCell(0,1).getContents())

log.info(Base)
log.info(Account)
log.info(Base1)
log.info(Account1)

0 votes
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 3, 2014

Hi Ilka,

Thank you for your question.

I would kindly suggest you on trying the following:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.crowd.embedded.api.User
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.util.SimpleErrorCollection

GroupManager groupManager = ComponentManager.getComponentInstanceOfType(GroupManager.class)

CustomFieldManager cfManager = ComponentManager.getInstance().getCustomFieldManager()
CustomField cf = cfManager.getCustomFieldObject(10005)
Object customFieldValue = issue.getCustomFieldValue(cf)

System.out.println(customFieldValue);

Kind regards,
Rafael

Suggest an answer

Log in or Sign up to answer