I am using the rules macro to dynamically display and hide fields and I'd like to extend that functionality so that, as well as unhiding fields, they are also made mandatory when they are visible. I'd also like the inverse of this meaning, when they are hidden, they are no longer mandatory.
I tried hunting through the rules functions and I cannot see one that sets field properties. Only field values.
Thanks
Yes, you can do this, by having two rules macros ... one for showing/hiding the second field, and the other to make it "required", by adding a Validation rule.
Details:
By "rules macro" I assume you mean the Confiform Rules for Field Definition macro. (I believe that in previous Confiforms versions the macro had a slightly different name, Confiforms Field Definition Rules, but I think they have the same or similar parameters.)
So you would need two rules macros -- one for showing/hiding the second field, and the other for making it required. I won't go into the first macro, since you seem to have that working ... but configuring the second one is quite different.
So lets say Field1 is a drop-down, with option IDs a1, a2, etc., and you want it to make Field2 required if Field1=a1.
Configure the second macro as follows:
Thanks a lot, Fred
There is a tutorial on our wiki to show this concept in action
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alex, interesting ... I forgot about that Tutorial.
But I notice that it is a slightly different solution. Your tutorial sets up the rules macro parameters as follows:
Both solutions seem to work just fine. Is there some advantage you can see between them?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Both will work (and I like yours better), but the one in our tutorial does not require any knowledge of regular expressions (which feels complicated to many users)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm trying to add multiple fields to be set to be required, but the rule only checks the first. I have the in a comma separated list, but I have tried regex matching to those fields which also failed.
What would I do as well if the field that I want to set to be required is a multiselect or user or dropdown?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What type of rule this is?
To validate multiple fields to be required you set the condition that matches the error case and set the message to show (that is using the validation rule)
There is no need to set field names, as this is not what tells required fields
See this page on how to use validation rules - https://wiki.vertuna.com/display/CONFIFORMS/Conditional+validation+for+required+field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is a validation rule.
In that case, where can I find a list of error cases for each type of field (dropdown, radio group, user etc)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure I get the question.. you decide the condition for the rule to "fail" and you decide what error message to show.
With validation rule you describe the condition that is illegal for submission and what message to show to the user when this happens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a text field where I want a user to input a title, and I want a conditional rule that checks to see if the user has typed something in it. For text fields, myField:[empty] is the condition that is illegal for submission.
My question is, what is the equivalent illegal condition for other field types such as dropdowns, radio groups, or user fields? Or is "[empty]" the condition that can satisfy my needs for any field type?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same [empty] check can be applied to any field type
https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Filters
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am trying to get this working for a drop down scenario but its not working.
I have a drop down with ID's as text like, "Sch", "Usch", "Ex".
Use case is:
IF a user selects "Usch"
Then another text field is required. Field name is called "CDBFUnplanned"
Field CDBFUnplanned is checked as Required.
Rule is setup as follows
Condition = ReleaseType:Usch AND CDBFUnplanned:[empty]
Action = Validation Rule
Field name (or regular expression) = Empty
When I go back to the form if the hidden field CDBFUnplanned is still required if another Release Type is selected.
Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You cannot have a field set as required in Field Definition and accept empty values into it.
Field should be set as not required.
See an example https://wiki.vertuna.com/display/CONFIFORMS/Conditional+validation+for+required+field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Coming back to this.
Field is set as Not Required but the examples are just not working. Kind of a different use case now.
When Release Type is set to Sch (The id) I would like to make a text field required.
This is how I have it setup.
Condition
ReleaseType:Sch AND BusinessValue:[empty]
Action to Execute: Validation Rule
Field Name : Blank
Message: Business Value is required if Scheduled
Business Value is not required in the field definition
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Very quick test form
And the storage format for this test form:
<ac:structured-macro ac:macro-id="256194ed-e1ba-42b1-94cf-c7b17966768f" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">myform</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="ee91f97f-045f-4ea5-9300-0c423801d289" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">myform</ac:parameter>
<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="c558e2db-b100-4e9e-a15a-141e4f2437f4" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">ReleaseType</ac:parameter>
<ac:parameter ac:name="fieldLabel">ReleaseType</ac:parameter>
<ac:parameter ac:name="values">false[Sch=Sch|NA=NA|]</ac:parameter>
<ac:parameter ac:name="type">select</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="84656bb9-34a4-4f1d-adfc-3687632634e7" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">BusinessValue</ac:parameter>
<ac:parameter ac:name="fieldLabel">BusinessValue</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="949d5236-5d81-4680-82ab-5c6a4e0ff3b6" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">ReleaseType:Sch AND BusinessValue:[empty]</ac:parameter>
<ac:parameter ac:name="fieldName">Business Value is required if Scheduled</ac:parameter>
<ac:parameter ac:name="action">Validation rule</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This works thank you!
The reason I thought it wasn't working was that I have several required fields and was not filling out the whole form when testing the use case.
The message only pops up after every other required field criteria is met.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, that is an additional rule and that is applied after all the standard rules are met
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I followed same steps but getting below error after populating all field values.
Rules applied:
actionFieldName = APPLICATION | condition = SHIRT:[empty] | action = Validation rule
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The error seems to be related to some incorrect regular expression
There is no need (in most cases) for the regular expression when you use the Validation Rule
At the moment, from what I see is that you validation rule will check the SHIRT is empty or not and in case if it is - it should fail the validation (assuming you have also put the message to show when the validation fails)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.