One of the most difficult things to get my head around as a newcomer to AwareIM is context in Processes.
As a Magic developer the paradigm is quite different so it needs a lot of trial and error and nut scratching to “Get it”
Fortunately Support at Aware is terrific and where able to clarify some points for me. I am sure many have no trouble coming to grips with it but I have found over the years…..If you have a question, never be afraid to ask it…usually many others are just dying to ask the same question.
So….here are some notes that might make it a tad clearer….
1: The context of a process is ALWAYS limited to objects specified as process input.
2: Inside a process you can add more objects to the context by issuing FIND or CREATE
3: When you perform an action like modify an attribute it applies to ALL objects in the context, for example FIND ALL Customer Customer.Name=’John’ This will apply to all customers in the context
4: When you call a sub-process from a process… Let’s say a subprocess has Customer object as input The calling process has 3 customers in the context: FIND Customer WHERE … Subprocess The Subprocess will be called as many times as there are customers in the context And the subprocess will NOT see any objects from the calling process context other than those that it has been called with.
5: A Sub Process can take more than one object as input from the calling Process. If there are several objects each the process will be called for every combination of parameters But usually you will write your calling process in such a way that there is only one instance for extra parameters.
Example: In the same Process…..
Rule 1 FIND Customer Rule 2 FIND Role Rule 2 does NOT get executed for each Customer and Customer will not be in Context for Rule 2. However, if the condition of the second FIND uses Customer, for example FIND Role WHERE Role.Name=Customer.Name The Customer will be taken from the context and it will be the first one.
6: Only sub-processes are executed several times – one for each instance of parameter in context A really good discussion regarding this issue can also be found here.