How do I populate the child value of a cascading list from a select list

Originally asked by Karen Jennings on 17 March 2021 (original question)


I have 2 select fields in ServiceNow that I need to populate a cascading list in Jira Cloud. I can get the parent value populated but I cannot get the child value to populate.

ServiceNow outgoing sync:

replica.category = entity.category
replica.subcategory = entity.u_subcategory

Jira Cloud incoming sync

issue.customFields.“Category/Subcategory”.value = nodeHelper.getCascadingSelect(
nodeHelper.getOption(issue, “Category/Subcategory”, replica.category),
nodeHelper.getOption(issue, “Category/Subcategory”, replica.subcategory)
)

ServiceNow is sending the info because when I use debug.info(“replica.subcategory is ${replica.subcategory}”) I get the the following:

[replica.subcategory is Decommission]

This works the other way. I can get the cascading list to populate 2 separate fields in ServiceNow

Jira outgoing sync

replica.customFields.“Category/Subcategory” = issue.customFields.“Category/Subcategory”

ServiceNow incoming sync

//Category
entity.category= replica.customFields.“Category/Subcategory”?.value?.parent?.value
//Subcategory
entity.u_subcategory = replica.customFields.“Category/Subcategory”?.value?.child?.value


Answer by Francis Martens (Exalate) on 18 March 2021

What is the result of

nodeHelper.getOption(issue, "Category/Subcategory", replica.subcategory)

Comments:

Karen Jennings commented on 18 March 2021

I get this result: [nodeHelper.getOption is null]

Francis Martens (Exalate) commented on 18 March 2021

Can you check the value of replica.subcategory and look it up in the option list .
(Make sure there are spaces or other tricks which make it hard for the exalate to find the value)

Karen Jennings commented on 18 March 2021

When I use debug.info(“replica.subcategory is ${replica.subcategory}”) I get the the following:

[replica.subcategory is Decommission]

The available values on each side match. These were copied from ServiceNow into Jira when we set up this field. I verified there are no trailing spaces for any of the values on each side.

ServiceNow options:

Jira options:

When I look at the payload from ServiceNow it shows this:

"category": "Network",
 "subcategory": "Decommission",  
  
When I look at the Jira payload it shows this:
 "Category/Subcategory": {
        "id": 10036,
        "name": "Category/Subcategory",
        "uid": "10036",
        "type": "CASCADING_SELECT",
        "value": {
          "parent": {
            "id": "10024",
            "value": "Network"
          }
        }
      },  
  
Is there something else I can check for the options?
Francis Martens (Exalate) commented on 18 March 2021

Oopsie :blush:

You should use the getCascadingSelect method - more about it here

Karen Jennings commented on 18 March 2021

That worked!

It looked like this for Jira Incoming:

def parentcat = nodeHelper.getOption(issue, “Category/Subcategory”, replica.category)
issue.customFields.“Category/Subcategory”.value = nodeHelper.getCascadingSelect(
parentcat,
parentcat.childOptions.find{it.value == replica.subcategory}
)

Thank you so much!

Francis Martens (Exalate) commented on 18 March 2021

you’re welcome and thanks for providing the outcome.