Hello.
I am trying to recreate a sort of cascading list within scriptrunner. So basically creating two custom picker fields with the second one needed the value of the first one in order to show proper results. Eventually, both fields will be fed with an API request but for current step in developpment I am just using typical raw json responses.
The structure is as follows. For the first field.
def jsonBody_parent = """
[
{
"id": "1",
"name": "Hello"
}, {
"id": "2",
"name": "HYUNDAI"
}, {
"id": "3",
"name": "Toyota"
}, {
"id": "4",
"name": "Demo"
},
{
"id": "42",
"name": "The response to the universe"
}
]
"""
The second level is as follows:
def jsonBody_child = """
[
{
"id": "1",
"name": "specialized",
"parent_name": "HYUNDAI",
"parent_id": "2"
}, {
"id": "2",
"name": "rockrider",
"parent_name": "HYUNDAI",
"parent_id": "2"
}, {
"id": "3",
"name": "toto",
"parent_name": "Toyota",
"parent_id": "3"
}, {
"id": "4",
"name": "tata",
"parent_name":"Demo",
"parent_id": "4"
}
]
"""
So you can easily see that each first level entry has an id. The second level has a name and an id and a reference to the level one (I was testing both by id and name, for now I will filter by name but this does not really matter overall).
The ID of the Parent level is stored in customfield_19000 whereas the child is stored in customfield_19001
The issue I have is that I need to read the issue and gather the customfield_19000 value in order to further filter the second json before proposing it into the field.
importing com.atlassian.jira.issue.Issue
and then using the component accessor to get the customfield value does not work.
groovy.lang.MissingPropertyException: No such property: issue for class is thrown.
How to workaround this issue?
Thanks.