Hello,
I’m still learning how to use Confiforms.
I have a form that includes two fields: status (field type dropdown) and requester (field type user). I am trying to create two separate validation rules:
I used Rules for Field Definition macro. Here’s how I set it for the first rule:
And the second rule:
I can’t get either one to work. For the first rule, when I test it and change the status from 1 to 2, the validation rule always executes even if I (as the current user) is myself or login as Jane. Similarly for the second rule, if I change the status to 5, the validation rule executes even if I am or am not the requester.
What’s the correct way to set these rules?
Thanks!
Hi Alex,
Thanks for your reply. I made the changes and I still am seeing the same issues. The condition for each rule always triggers the rule to execute.
Is there something else I might be doing wrong?
Hi @NA1021
For your first rule remove the "Validation rule" parameter value and set the "Condition" parameter to be
hasChanged(status):true AND status:2 AND _previousState.status:1 AND !_user.firstName:Jane
And for your second rule, also remove the the "Validation rule" parameter value and set the "Condition" parameter to be
hasChanged(status):true AND status:5 AND !requester:[entry._user]
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I dont know what are you doing wrong, but this is clearly working for me...
Here is a quick demo:
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for creating the example. The macros looks the same as what I have albeit my form has more fields with other rules. I wonder if my something I did incorrectly in my other rules are the cause of the issue. I'll keep looking for now and report back if I find the root cause.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So I created a simple form like you did with a status field (dropdown) and a requester (user). Rule 1 worked. But Rule 2 , which had this condition as you suggested,
hasChanged(status):true AND status:5 AND !requester:[entry._user]
will always trigger the rule whether the current user is or is not the requester.
But if I changed the last AND clause and reversed it
hasChanged(status):true AND status:5 AND !_user:[entry.requester]
it would work correctly and only trigger if the current user is not the requester.
Does the order of the two comparands matter in a filter? In my case it seems to work one way but not the other.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Both filtering expressions work for me
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's what I would expect.
So, any clues as to why a simple form I have isn't behaving as it should? Is it something to do with my configuration? I have the cloud version of Confiforms and still on the trial period. Will it help if I uninstall and re-install?
Sorry for the questions, but I'm at a loss on what to do next. Any help from you or your team would be really appreciated. I would hate to not use Confiform if I can't understand why it won't work as expected.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is no point in uninstalling or reinstalling anything
Both conditions are perfectly valid and work just fine (just a different way of checking the current user against value in the "requester" field)
Share the storage format for your "simple form", so I can have a look and see what you have differently
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here you go.
<h2>Form Configuration</h2><p><ac:placeholder>(visible only to page editors - you can also hide it for everyone via “Hide form admin UI” parameter)</ac:placeholder>
</p><ac:structured-macro ac:name="confiform" ac:schema-version="1" data-layout="default" ac:local-id="6ee5fed9-e476-46ae-8158-e2b100f2663f" ac:macro-id="b7079a6e-a162-4bc6-9de3-ee10d65684f3"><ac:parameter ac:name="formName">myform</ac:parameter><ac:rich-text-body><p>This is your form definition, this defines the form and it’s fields</p><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" data-layout="default" ac:local-id="c65a6c6c-7c73-4f0e-9fa8-2fec5242305e" ac:macro-id="29b95196-46be-408d-8230-cea132458931"><ac:parameter ac:name="fieldName">status</ac:parameter><ac:parameter ac:name="fieldLabel">Status</ac:parameter><ac:parameter ac:name="values">1=Status 1|2=Status 2|3=Status 3|4=Status 4|5=Status 5|6=Status 6</ac:parameter><ac:parameter ac:name="type">select</ac:parameter><ac:parameter ac:name="required">true</ac:parameter><ac:parameter ac:name="macroHash">1793640440</ac:parameter></ac:structured-macro><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" data-layout="default" ac:local-id="931c0e92-2a1c-4e72-88ea-c6d118e73079" ac:macro-id="652d372e-e83c-4373-a8f4-a8864a975e36"><ac:parameter ac:name="fieldName">requester</ac:parameter><ac:parameter ac:name="fieldLabel">Requester</ac:parameter><ac:parameter ac:name="type">user</ac:parameter><ac:parameter ac:name="required">true</ac:parameter><ac:parameter ac:name="macroHash">-1792722281</ac:parameter></ac:structured-macro><ac:structured-macro ac:name="confiform-field-definition-rules" ac:schema-version="1" data-layout="default" ac:local-id="47d604ed-32f5-4640-a01a-4c238fa920b6" ac:macro-id="58e50d50-5671-4b55-8c9a-9f70065dea96"><ac:parameter ac:name="condition">hasChanged(status):true AND status:2 AND _previousState.status:1 AND !_user.firstName:Jane</ac:parameter><ac:parameter ac:name="fieldName">Only Jane can change to Status 2</ac:parameter><ac:parameter ac:name="action">Validation rule</ac:parameter><ac:parameter ac:name="actionFieldName">status</ac:parameter><ac:parameter ac:name="macroHash">197061313</ac:parameter></ac:structured-macro><ac:structured-macro ac:name="confiform-field-definition-rules" ac:schema-version="1" data-layout="default" ac:local-id="1e6be9e6-9b57-41a5-82a5-0493c4b457e6" ac:macro-id="f2219f78-4271-4970-a848-f90f11c28da1"><ac:parameter ac:name="condition">hasChanged(status):true AND status:5 AND !requester:[entry._user]</ac:parameter><ac:parameter ac:name="fieldName">Only requester can change status to 5</ac:parameter><ac:parameter ac:name="action">Validation rule</ac:parameter><ac:parameter ac:name="actionFieldName">status</ac:parameter><ac:parameter ac:name="macroHash">-1154435905</ac:parameter></ac:structured-macro><p /></ac:rich-text-body></ac:structured-macro><p> </p><h2>Editable CardView</h2><p>Data that you have provided (created by you)</p><ac:structured-macro ac:name="confiform-card" ac:schema-version="1" data-layout="default" ac:local-id="fbf1040f-4f5f-4a96-96ee-1991d3d002a0" ac:macro-id="6d9f56e3d39ef67a691734017dc63c3f"><ac:parameter ac:name="messageToShowWhenEmpty">You have not created any records yet</ac:parameter><ac:parameter ac:name="formName">myform</ac:parameter><ac:rich-text-body><p><ac:structured-macro ac:name="confiform-entry-edit" ac:schema-version="1" ac:local-id="dea38b6b-d737-48d4-8105-a645fb00f59e" ac:macro-id="293a3351-3b5f-4f88-b6bf-5264bfaa6b9d"><ac:parameter ac:name="deleteButtonLabel">Delete</ac:parameter><ac:parameter ac:name="cancelButtonLabel">Cancel</ac:parameter><ac:parameter ac:name="showCopy">false</ac:parameter><ac:parameter ac:name="inline">true</ac:parameter><ac:parameter ac:name="copyButtonLabel">Copy</ac:parameter><ac:parameter ac:name="showDeleteButton">true</ac:parameter><ac:parameter ac:name="editButtonLabel">Edit</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 work perfectly well for me - only the requestor can set the record to status 5... what does not work here for you?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So I start by setting the status of 1 and the requester as myself. I save the form. Then I edit and change the status to 5 and save again. The validation triggers even if I am the requester.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After trying different things, I finally got it to work. Not sure anymore what made it work, but at this point I'm just happy it works now. Thanks!
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.