JIRA REST API for Blank Cascading select list ID from ConfiForm input

Brian Karst April 30, 2020

We have a Select List (Cascading) custom field that contains the Divisions and Subdivisions that employees could work for. A while ago I got the input for the field working in my ConfiForm but I think the barbaric way I did it is breaking the ability for it to "update" and link my issues.

Searching how to input the ID's, i found the syntax

    {"id":"11111", "child":{"id":"22222"}}

So I set up a form with the ID's and set up a smart classifier and entered the code

"customfield_13062": {"id":"[entry.smartdepart.ParentID]", "child":{"id":"[entry.smartdepart.ChildID]"}}

This works fine when both the ParentID and ChildID have ID's, but not all ParentIDs have ChildIDs

I get an error because Jira doesn't like that the child ID is blank. (edited error message below)

com.atlassian.sal.api.net.ResponseException: Error communicating with Jira, {"errorMessages":[],"errors":{"customfield_13062":"Child Option id '' is not valid"}}

Used JSON:  "customfield_13062": {"id":"32410", "child":{"id":""}} }} }' 

 

I tried null and I can't remember what else instead of a blank in the form, nothing worked. Eventually I put the code for the child input into the ID in the form and used the code

"customfield_13062": {"id":"[entry.smartdepart.ParentID]"[entry.smartdepart.ChildID]}

where

Parent ID = 11111

and

Child ID = , "child":{"id": "22222"

 

This code works, if there is no childID it doesn't try to set one, and Jira doesn't have a conniption fit, but if there is one it enters the missing API code. 

Further development of my ConfiForm led tofrustrations with the IFTTT not linking issues. I started picking it apart and if I hard code an ID or remove the "customfield_13062" line the IFTTT links issues just fine.

 

Is there a better syntax to allow Jira to accept there sometimes being a ChildID and sometimes not?

1 answer

0 votes
paulopeixoto January 8, 2021

Hello Brian.

I had the same problem and couldn't find a solution, but by trial and error I found out how to do it.

If you send no child field at all jira accepts that as no child selected.

Using your example, this should work:

"customfield_13062": {"id":"32410"}

Suggest an answer

Log in or Sign up to answer