unique not working?
Asked by Alan Nelson:

I have a simple form that has a name field that is created dynamically. When I set the validation for that field (it's a Read Only field) I get a validation error whether the name exists or not. I cannot get past it.


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@Alan Nelson](/t5/user/viewprofilepage/user-id/4523084)

The question is incorrectly marked as for bitbucket and that caused a lot of confusion

Actually it is about ConfiForms and ConfiForms is only available in Confluence (server and cloud)

Here is what you can do (2 options): <http://recordit.co/vN28CsxTdC>

Enclosing storage format for you to copy

```
<p>
<br/>
</p>
<p>Check with [unique] on the field definition</p>
<ac:structured-macro ac:macro-id="f2b7d1a9-533d-4c97-97e1-de52e87bd4b5" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="ad7e81e7-b694-4d6e-a661-f4b3a213bb68" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="type">Embedded</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="dd0cd355-8787-4c9f-a569-a8bf723125b9" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">uname</ac:parameter>
<ac:parameter ac:name="fieldLabel">uname</ac:parameter>
<ac:parameter ac:name="validationMessage">Unique Name field value must be unique</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
<ac:parameter ac:name="validation">[unique]</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<p>Check with validation rule</p>
<ac:structured-macro ac:macro-id="1e8e2a8c-e8a7-4ba4-8a17-eea81f119374" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">f1</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="a74ceea2-b6fd-4a5f-9413-c1ca9750c769" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="type">Embedded</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="ff1e30f0-4073-4f6d-b683-03c9336858f0" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">uname</ac:parameter>
<ac:parameter ac:name="fieldLabel">uname</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="5d9f574f-ed93-4e00-9c7f-ffd299ceafa2" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">uname:[entry.uname] AND _count:&gt;1</ac:parameter>
<ac:parameter ac:name="fieldName">Unique Name field value must be unique</ac:parameter>
<ac:parameter ac:name="action">Validation rule dataset</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
```

Hope it helps

Alex

comments: author: Alan Nelson
body: Thank you Alex, the issue was on my rule to create 'uname' (CONCAT 2 other fields) I was running it as a validation (Field name was blank) rather than having it watch a specific field. Once I changed that it worked.


author: Alan Nelson
body: Problem = \[unique\] validation validate EVERYTHING as existing

What Form? = My ConfiForm

What name Field? = It's called 'uname' and is filled when the form is created using the values from two other fields.

Validation = in the 'Validation Rules' of the field I have '\[unique\]'

Error = "Unique Name field value must be unique" It throws this error no matter what I put in the field.

comments: author: Alan Nelson
body: It even throws when it's blank.


author: Nic Brough -Adaptavist-
body: Could you explain in a bit more detail what the problem is? What form? What name field? What is creating it dynamically, and what is the validation? (And the validation error?)

comments: author: Alan Nelson
body: Problem = \[unique\] validation validate EVERYTHING as existing

What Form? = My ConfiForm

What name Field? = It's called 'uname' and is filled when the form is created using the values from two other fields.

Validation = in the 'Validation Rules' of the field I have '\[unique\]'

Error = "Unique Name field value must be unique" It throws this error no matter what I put in the field even left blank.


author: Nic Brough -Adaptavist-
body: Thank you for that!

I know I did a barrage of questions, but I was very stuck on where the problem was. I'm not familiar with Confiforms in Bitbucket, so I'm stuck, but hopefully there's someone who can help out!


Tags: bitbucket-server

confiforms

confluence

server