How do I validate ConfiForms Jira form field value for Jira Issue?
Asked by Adrian M:

I have a ConfiForms Jira form field that is shown on the form when a certain selection is made from another dropdown. Else it is hidden. Hence this field cannot have the 'Required' checkbox selected. There is validation that will show a form error if the field is empty.

To select and submit a Jira issue;

1. The user can input the Jira key e.g. ABCD-1234.
2. The located Jira issue is shown under the textbox (issuekey, summary and status)
3. The user clicks the issue to select it.
4. The issue that is selected then appears in the textbox
5. User submits the form.
6. This form Jira field value is saved in the Description field in Jira

If the user types in the Jira key e.g. ABCD-1234 but does not click to select the issue, then:

* The validation for empty field does not get triggered as the validation sees a value in there.
* However this value, that is in the form field, does not get saved to the description field. That part of the description field text is blank.
* If the user does click to select the Jira issue then the description saved in Jira is only the issuekey as the value. Summary and status does not get saved.

How can I do the following?

1. Validate that the form is not empty such that it contains a selected Jira issue and not just a typed in value or no value.
2. Save the Jira issuekey, summary and status to the Jira description field.


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@Adrian M](/t5/user/viewprofilepage/user-id/5037760)

Is this a question about the ConfiForms? I believe so, but nothing tells me that for sure (no tags, no mentioning of ConfiForms...)

Alex

comments: author: Adrian M
body: Sorry yes, this is about ConfiForms. I've added the tag now.


author: Alex Medved _ConfiForms_
body: Ok, thanks for clarifying

You can add a conditional validation ([Validate rule](https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Definition+Rules#ConfiFormsFieldDefinitionRules-Validationrule)) for the "Jira field" to report when it is empty (not selected from the offered choices)

Alex


author: Adrian M
body: I am using 'Conditional validation for required field' as follows. getting the same result. If a value is typed in the textbox and not selected then the validation action does not get executed but no value from that field gets saved to Jira.

The user should select a value from the CSPJiraTicket Jira field and that should get saved to the Description field in Jira. Else a form error message is displayed.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/308217i99783AA1DC02D760/image-dimensions/165x214?v=v2 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/308218iFA4FD6710F16702E/image-dimensions/177x272?v=v2 "image.png")


author: Adrian M
body: [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) I'm still trying to resolve this. I created a very simple form with a similar structure of my live form and I'm able to duplicate the issue.

Form has two fields. Summary set as required. And "Jira Issue" field has validation if field is empty.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/314259i9C6D0C0A124B29FB/image-dimensions/383x152?v=v2 "image.png")

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/314260iAAFA91107AC4A454/image-dimensions/409x214?v=v2 "image.png")

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/314269i7DDE24BFC8DDC562/image-dimensions/417x161?v=v2 "image.png")

----------------------------

On clicking the button with no value in the Jira Issue field the validation is triggered

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/314261i0949A59E1302104D/image-dimensions/363x192?v=v2 "image.png")

----------------------------

Enter a Jira key in the Jira Issue field. Click to select the Jira Issue from the dropdown. Click the submit (Create Jira Issue) button. Issue is successfully created with "Jira Issue" field value in description field in Jira.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/314262i4A6EA748E634278D/image-dimensions/363x208?v=v2 "image.png")

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/314264i41C4731F84043127/image-dimensions/221x184?v=v2 "image.png")  

--------------------------------

Enter a Jira key in the Jira Issue field. **Do not click to select the Jira Issue from the dropdown. Click outside the box.** Click the submit (Create Jira Issue) button. Validation if empty does not get triggered. Issue is successfully created in Jira but "Jira Issue" field value is **not** in description field in Jira.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/314266i6AAF0A099832DA6C/image-dimensions/291x166?v=v2 "image.png")  
![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/314267iDCC32EF73CDB357C/image-dimensions/204x148?v=v2 "image.png")

----------------------------------  

How can I validate that the "Jira Issue" field has a valid Jira Object value?


author: Alex Medved _ConfiForms_
body: Hi [@Adrian M](/t5/user/viewprofilepage/user-id/5037760)

In ConfiForms version 3.10 we have introduced a property that you can ask from a Jira field to see if that "exists" (links to a valid Jira issue)

That could be then used in the Validation rule, in the condition

```
JiraIssue.exists:false
```

Alex


author: Adrian M
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630)

This is my Validation : (JiraTicket:\[empty\] OR (!JiraTicket:\[empty\] AND JiraTicket.exists:false))

> #1
>
> Input field has no value
>
> Result on Submit - Validation error message is shown

> #2
>
> Input field has a Jira Issue selected
>
> Result on Submit - No Error

> #3
>
> Input field value is - XXXX
>
> Error message below Jira field - "Request could not be completed: Status: 404 with message: and response: '{"errorMessages":\["Issue Does Not Exist"\],"errors":{}}'"
>
> Result on Submit - No validation error message is shown and form can be successfully submitted

For scenario #3 how can the form submission be prevented and show the validation error message instead?

Note:

1) This Jira issue form field value is being saved in the description field in Jira and not an issue field in Jira. So Jira wont throw an error if no/invalid value is passed, in this case.

2) The documentation states "myfield.exists - returns true or false to verify if the value stored in this field corresponds to Jira issue". It is not clear what it will return if a String or Null value is passed to JiraTicket.exists


author: Alex Medved _ConfiForms_
body: Checking for **JiraTicket.exists:false** should be sufficient

No other expressions needed


author: Adrian M
body: **Validation - JiraTicket.exists:false**

Validation error message is not shown when no value (empty) is passed and form can be successfully submitted.

Validation message is shown when String (e.g. XXXX) is passed.


author: Alex Medved _ConfiForms_
body: **JiraTicket:\[empty\] OR JiraTicket.exists:false**


Tags: confiforms

confluence-cloud