Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Confiforms: Can I display field name in error message triggered by validation rule?

fbunting May 23, 2021

In Confiforms I have a number of fields for which I want to apply the same validation rule(s). I don't want these permanently part of the Field Definition macro for each field, as I want to be able to turn the validation on or off based on the value of a checkbox.

I am able to do this using a 'Confiforms Rules for Field Definition' macro, with a 'Validation rule' action, and listing all the fields I want to apply it to.  

This seems to be working, and displays the error message on Save.

However, I would like the error message to include the name of the field that triggers the validation error.  (I'm OK if it displays 10 error messages if there are 10 fields that fail validation, but I would like each error message to include the name of the affected field.)

Is there a way to do this?

1 answer

1 accepted

1 vote
Answer accepted
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 23, 2021

Generally the idea is to set specific validation for each field you need and this allows you to show unique error messages specific to these validation rules

If you put the field names into the validation rule (first parameter on the macro), as comma separated list and when validation gets applied you will see these fields marked/highlighted with "red" border

This is what is possible at the moment.

Otherwise split your validation rules into different ConfiForms Field Definition Rules macros with unique validation rules and error messages

Alex

fbunting May 26, 2021

Yes, I have done that with several rules (one rule per field) ... but in this case I want to apply the same rule to a large number of fields.

I forgot about the highlighting in red, and that works fine for this case! 

(It would be a slight problem if there might be multiple validation errors that each applied to multiple fields ... as it would be unclear to the user which error message applied to which highlighted fields.  But I think I can avoid that by writing the validation rules carefully.)

Thanks again, Alex!  As always, this is a brilliant plug-in, and you support it well!

fbunting May 26, 2021

Oh, another place something like this would be useful is in a universal rule to replace one value with another.

E.g. if I want a rule that detects when a user changes a field value to Foo, and change it to Bar ... and then apply that rule to 15 different fields ... then I have to create 15 separate rules, one for each field.

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 26, 2021

Why to create 15 separate rules if can have a rule that sets multiple fields at a time?

https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Definition+Rules#ConfiFormsFieldDefinitionRules-Setvalue can set multiple fields without any problem

field1=some value&field2=another value&field3=1

Alex 

fbunting June 30, 2021

Since the rule is dependent on the current value of the field, I can't apply the same rule to other fields.

E.g. it watches field1, and when field1=Foo, then change the value of field1 to Bar.  Same with field2. Same with field3.

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 1, 2021

You can set the same rule to watch multiple fields - given their names in a comma separated list (first parameter in the macro)

fbunting July 7, 2021

Yes, but if field1 changes, I don't want to change field2.

Example: Imagine that all of these are Status fields, and I want a rule that says "if user changes the value to COMPLETED, then automatically change it to CLOSED."  I can list all the fields to watch in a comma-separated list (field1, field2, field3) ... but if user changes field1 to COMPLETED, then I don't want to apply the same change (change it to CLOSED) to field2, field3, etc.

I can do this by creating a separate rule for each field. But it would be nice if I could write the conditional in a way that references "value of this field."

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events