Introduction
If you want to prevent a user from entering nonsensical or impossible data, like entering a future date as a date of birth, you must configure a server constraint, or hard error. A server constraint is a condition that, if evaluated to true, will not allow the application to save the record to the database. Instead, the application will display a message to the user informing them why the save failed.
Prerequisites
- The entity must exist.
- The form must exist.
|
Quick Steps |
| 1 |
Open the entity |
| 2 |
Open the Conditions section, then open the Expression section |
| 3 |
Add a new expression |
| 4 |
Enter the Expression Name, then click OK |
| 5 |
Add a new condition, then enter the expression. |
| 6 |
Enter the Message ID |
| 7 |
Open the Constraints section, then open the Server section |
| 8 |
Add a constraint, enter the details, then click OK |
| 9 |
Save the entity |
Detailed Steps
Step 1. Open the entity.
The form's entity is where you configure its validations, including server constraints.
Step 2. Open the Conditions section, then open the Expression section.
This is where the entity manages its expressions.
Step 3. Add a new expression.
Click the plus icon to add a new expression.
Step 4. Enter the Expression Name, then click OK.
Make sure your name is descriptive enough to know what it refers to later.
Step 5. Add a new condition, then enter the expression.
Click the Add Condition button to add a new condition expression.
Enter a condition expression. Whenever it evaluates to true, it will prevent the application from saving data.
The expression above uses a query to return the current date to compare to the Birth Date attribute. If you do not already have the query, you need to create it, as below.
Step 6. Enter the Message ID.
This example uses a configured message from the framework's messages table. Select Message ID and enter the ID to populate the text of the message.
Alternatively, you can enter a Message Description.
Step 7. Open the Constraints section, then the Server section.
Now that you have the expression, you can add it as a server constraint. Select the Server option and click the plus icon to add the constraint.
Step 8. Add a constraint, enter the details, then click OK.
Click the plus icon to add a new server constraint.
Enter the condition you just created and enter the Mode to determine when the application applies the constraint (new records, existing records, or both). You must also make the constraint active.
Step 9. Save the entity.
Now the constraint will apply to all forms based on this entity.
What are the improvements over S3 Version 6?
Previously, a C# expression was written. And then it was added to the Hard Error section. The process is enhanced. Previously, single attribute expressions could be added. Now, you can add multiple attributes and conditions to it. Also, the expression can be formulated using various options like query, attributes, rule, and constant.
This post is part of the Maintenance Form topic. Click here to open the Maintenance Form Overview.
#Xelence
#Forms