Welcome!
This community is for professionals and enthusiasts of the Genio platform.
Share your questions and challenges, and help your partners!
"Write condition" in a Field of a Form doesn't seem to be working
I set the "Write condition" to be FALSE, but it is possible to edit the field normally:
How can I define a "write condition" in a single field within a form?
The 'write condition' is a validation rule. It will only run when the user presses the save button in the form. So its an expected behavior for the field to be open.
To block the field from being edited you can hide it or you can block it. These rules can be specified in the 'Show When' and 'Disable When' respectively in the table field specification. The 'Fill When' has the additional property of clearing the value of the field when the condition is false, so it should be used with care.
In the form field specification only the 'show when' is available. Its best practice to think about these kind of business rules in terms of the business entities, not in terms of the form interface. Business rules should be as traversal as possible throughout the application to avoid data and interface inconsistencies (if the user is able to do operation X in one interface, the same user should be able to do operation X in any interface).
The expression that I want to set in "write condition" in this field is [ANALI->CODPESS6]==GetEph("USER")
The field [ANALI->CODPESS6] is specified with "DG Default (once)" and GetEph("USER") and it works nicely: when a new record is created in the "ANALI" table, this field is filed with the user logged.
When I set the 'Disable When' in the table field specification with the condition [ANALI->CODPESS6]!=GetEph("USER"), it disable the field in all situations whatever the field [ANALI->CODPESS6] have the logged USER or not.
But if I set the condition [ANALI->CODPESS6]==GetEph("USER"), it enable the field in all situations whatever the field [ANALI->CODPESS6] have the logged USER or not.
The definition seems correct, hard to tell more without going into debug. Assuming the "USER" is in context when the form is opened and its indeed the same value, then it can be a failure of the comparison operator.
Try to apply the KeyToString function to both sides in order to normalize the inputs:
KeyToString([ANALI->CODPESS6])!=KeyToString(GetEph("USER"))
Let me know if it works this way.
However, if I set the "Write condition" in the table field specification (not in the form specification) with the same condition [ANALI->CODPESS6]==GetEph("USER"), it works as expected
With KeyToString([ANALI->CODPESS6])!=KeyToString(GetEph("USER")) in the field 'Disable When' don't work: the field remains enabled whatever the user.
The opposite condition: KeyToString([ANALI->CODPESS6])==KeyToString(GetEph("USER")) have the same behavior: the field remains enabled whatever the user.
At this time only the "Write condition" defined in the table field is supported and is validated on the server side in the save process.
If you need to block the field forever just on this form, I would recommend changing the help type to "Fixed".
Also, if you need to block the field on all forms, based on a condition, you can use the "Disable when" condition in the table field.
Keep Informed
About the Community
Question tools
Stats
Asked: 11/10/2019 15:29 |
Seen: 1947 times |
Last updated: 13/10/2019 18:10 |
"The 'write condition' is a validation rule. It will only run when the user presses the save button in the form."
However, when the user press the save button in the form, it saves the information normally, ignoring that the "write condition" is false.
In my case, I need to put an expression to verify if the logged user is the "owner" of the "Observação" (not just "0==1". I seted this expression only to verify that the 'write condition' is not working in single fields of a form)