This function is useful in rules that handle a different context than the Process entity. Other uses of Me.Context are:
•When the rules are going to be used in Add or Edit forms of a table, including: rules of visibility, editing or the mandatory nature. In these cases, the context of the expression (the start point of data navigation) is the collection entity (of the one-to-many relationship) where the rule is evaluated.
•When the rules are going to be used in a nested form, as rules of visibility, editing or the mandatory nature of attributes.
•When the rules are going to be used in a button that is in a nested form or in the form to Add or Edit records of a table. In these cases, the context of the expression (the start point of data navigation) is the collection entity (of the one-to-many relationship) where the rule is evaluated.
•When the rules are going to be used as rules to filter information from a combo or a search window. In these cases, the context of the rule must be the entity where the combo or the search window is located.
In a Loan Request Process the customers’ income is an important variable. According to the bank's policies, a loan cannot be granted to a customer who has an annual income of less than $15,000 and every customer with an annual income greater than $90,000 has to be verified.
The validations that are required will be controlled from the Applicants Analysis activity, in order to give immediate feedback to the customer and to make sure that only valid cases arrive to the Verify Applicants Information activity.
The information in the Applicant Analysis activity is shown as follows:
If the customer has an income less than $15,000, a message should be displayed to the user when editing the customer as shown below.
To configure this validation you have to use a Form Validation. As the context of the form where the customer is edited is different from the Process Entity, Me.Context is used to check if every customer complies with the incomes policies.
The validations will be performed using the following data model.
Notice that a request may have more than one customer and a customer may be in more than one request (N-M relationship).
1. Go to the third step of the process Wizard and click on the Applicants Analysis activity.
2. Go to the Advanced tab of the Customers collection. Assume we have already configured an Edit Form for this collection.
3. Click the expression icon of the Validation expression property of the Edit options and create an expression.
4. In an expression element obtain the values to be compared (High income, low income, and customer income).
Validate if the Customer Income is less than the Low Income. In this case a validation is thrown.
Now validate if the Customer income is greater than the High income. Use Me.Context to set the indicator for customers whose income is to be verified.
//Obtain the values to be compared
//Evaluate if the customer income is lower than the low income
CHelper.ThrowValidationError("The income is too low to apply for this loan")
//Evaluate if the customer income is higher than the high income