Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to specify null value for select list (single choice) field in JSON at new issue creation

Michael Okhotin July 2, 2024

Hi everyone! 
We use a custom script postfunction to create new issue at specific transition where custom fields' values are copied from initial issue.
All in all it works fine but now I need to update it with some select list (single choice) fields values.
All good when I define value as "customfield_11111" : {"value" : "Red"}
But in some cases I don't know whether field is filled in the initial issue or not, so I have to include an option when value in new issue is null and I have no idea how to define that. 
Options as "customfield_11111" : {"value" : "null"} , "customfield_11111" : null , etc do not work due to 400 Error. 

I would appreciate any idea. 
Thanks in advance. 

1 answer

0 votes
Tuncay Senturk
Community Champion
July 2, 2024

Hi @Michael Okhotin 

If you do not add the customfield_11111 at all, it will be null unless you have a default value for that field.

On the other hand, if this is a REST service call and you use the PUT method  for /rest/api/2/issue/{issueIdOrKey} with json below

{
    "fields": {
        "customfield_11111": null
    }
}

 then, it should set/update the field with a null value.

 

Michael Okhotin July 3, 2024

Hi @Tuncay Senturk 
I cannot exclude customfield_11111 field from Json because I don't know whether is will be used or not. 


Unfortunately solution mentioned above does not suit me because I get 500 Error. Maybe something is wrong with the script.  

Tuncay Senturk
Community Champion
July 3, 2024

500 is a server error, did you have a chance to check the logs? 

Michael Okhotin July 3, 2024

Yep I know that it's Internal Server Error message. I only see this code or error and no addiitonal info. 

Suggest an answer

Log in or Sign up to answer