Closed
Solved
Difference between Declare Onchange and Declare Constraint
Help me to find difference between Declare Onchange and Declare Constraints. I found that I can implement same validation using both.Which is better in performance?
Hi Saheli,
When declare constraint is defined on some property then whenever the proeprty value changes the system checks if the constraint is valid and if and only if it evaluates to true it allows to save the page to the database else it throws the error.
You can refer the follwoing example:
A Constraints rule records an expected relationship between property values, such as:
ActualExpense("December") is never greater than BudgetExpense("December").
As with expressions, the system monitors whether the constraint is met each time either value changes. If the constraint becomes false, the system adds a message on the page containing the left-hand property (ActualExpense(), in this case), marking the page as not valid. Pages that are not valid cannot be saved to the database.
Hi Saheli,
When declare constraint is defined on some property then whenever the proeprty value changes the system checks if the constraint is valid and if and only if it evaluates to true it allows to save the page to the database else it throws the error.
You can refer the follwoing example:
A Constraints rule records an expected relationship between property values, such as:
ActualExpense("December") is never greater than BudgetExpense("December").
As with expressions, the system monitors whether the constraint is met each time either value changes. If the constraint becomes false, the system adds a message on the page containing the left-hand property (ActualExpense(), in this case), marking the page as not valid. Pages that are not valid cannot be saved to the database.
Where as Declare Onchange rule causes computation to occur when the value of the "watched" properties changes.