Understanding Contextual Referencing
The Rules Engine includes a feature called Contextual Reference. This feature ensures that when Functions are called by other Rules (Calling Rules), the Entity of the Calling Rule is passed to the called Function.
The following is an example of a Rule using Contextual Referencing which does the following:
-
Selects all relevant Courses.
-
For each Course, determines whether en enrollment record exists in Year 1 of the academic program according to the APT schedule record using user defined Function.
-
Selects the appropriate result which is stored in the result record as Result Type “ECTS”.
-
Uses the result value obtained in the previous step to calculate the sum of credit using delivered math Function “Add” in Category “Math”.
-
Evaluates whether total credit is enough to progress to year 2 of the academic program using user defined Function.
This example illustrates the fields and controls on the Example of Progression Rule for Contextual Reference Example (1 of 2). You can find definitions for the fields and controls later on this page.

This example illustrates the fields and controls on the Progression Rule for Contextual Reference Example (2 of 2). You can find definitions for the fields and controls later on this page.

The Functions used to perform summing of Total Credit (Steps 4 and 5) receive either an Input value of type Variable or Property directly from the Calling Rule. An input Variable is all that these Functions need to execute the required processing logic. The Function performs a series of evaluative Statements using the single input Variable TotalCredit and passes back the result into Variable Progressionoutcome. The Function has no Entity of its own and is without criteria.
Shown below is an example of the custom Function “NLD Function Credit Progression Year 1”.
This example illustrates the fields and controls on the Example of Progression Function for Contextual Reference (1 of 2). You can find definitions for the fields and controls later on this page.

This example illustrates the fields and controls on the Example of Progression Function for Contextual Reference (2 of 2). You can find definitions for the fields and controls later on this page.

Next is an example of the Function “Schedule Check, Check specific Year of Program against the Attempt”. This Function does have its own Base Entity “APT Attempt”, but only Input and Output parameters are defined in the Call Statement shown after the Function example. The criteria identifying the exact APT Attempt are not explicitly passed from the Calling Rule to the Called Function.
However, when the Function is called, the exact Attempt information is passed from the calling Rule to the called Function by virtue of Contextual Reference. This is because the called Function's Base Entity is APT Attempt which is the same context that the Calling Rule is working from when retrieving Attempts using the FOR-EACH loop.
This example illustrates the fields and controls on the Example of Program Course Function for Contextual Reference. You can find definitions for the fields and controls later on this page.

This example illustrates the fields and controls on the Example of Call Statement for Contextual Reference. You can find definitions for the fields and controls later on this page.
