Hi,
I'm using a Jira automation rule to fill out Ticket 1 based on the fields in Ticket 2. I'm using the Create Work Item component with the additional fields.
I have a custom field customfield_15842 that is a drop down selector for the user. Sometimes it's empty and that's okay. However when it IS empty, and the automation is run, there is an error "Specify a valid value for YourCustomValue (customfield_15842 ),", which I gather is because it's trying to bring in a null value.
What I would like to do is write this logic such that if the value is empty, then just keep the field as `None`. But I'm having trouble writing the correct logic for this, and it keeps erroring.
I've tried things similar to the following with no luck:
"customfield_15842" : { "value": "{{triggerissue.customfield_15842 | null}}" }
"customfield_15842" : { "value": "{{#if(or(customfield_15842.isEmpty,equals(customfield_15842,null)))}}null{{/}}{{customfield_15842}}" }
"customfield_15842" : { "value": "{{#if(or(customfield_15842.isEmpty,equals(customfield_15842,null)))}}""{{/}}{{customfield_15842}}" }
"customfield_15842" : { "value": "{{#if(customfield_15842.isEmpty)}} null"}
"customfield_15842" : { "value": "{{#if(customfield_15842.isEmpty, null, triggerissue.customfield_15842)}}{{/}}"}
Any help appreciated, thanks!
--------
Update: Solved!
It seems that when dealing with these drop down type fields, the if statement encloses the "setting" aspect. Something like this worked for me.
{{#if(exists(triggerIssue.customfield_15850))}}
"customfield_15850": { "id": "{{triggerIssue.customfield_15850.id}}" } {{/}}so when for example combining drop downs and regular text fields, it would look something like this, with the comma being contained inside the if statement
{{#if(exists(triggerIssue.customfield_15850))}}
"customfield_15850": { "id": "{{triggerIssue.customfield_15850.id}}" }, {{/}}
"customfield_15851" : "{{triggerissue.customfield_15851}}"
A second aspect about copying drop down values is in particular cases where the fields may have different names but the same values, you cannot use the .id attribute. In cases like this, you can use the value attribute instead:
{{#if(not(exists(customfield_10550)))}}
"customfield_10550": { "value": "{{triggerIssue.customfield_15845.value}}" },
{{/}}