Welcome to the IDIOM Decision Products Knowledgebase.

alt
 



Recent Comments

    Creating Collections from other Collections Using External Context

    Feargus Norton  3 February 2010 02:45:55 PM
     

    Friday, October 23rd, 2009
    This example shows the use of the external context operator to iterate through two lists concurrently. The scenario is that a superannuation member has multiple ‘rollovers’, which is when the member moves to or from another administrator. Each rollover is associated with a competitor administrator, who becomes a ‘payee’.  The purpose of this example is to build one consolidated list of ‘Payees’ from multiple lists of rollovers. To do this, we need to take each name in each rollover list, and then iterate through the Payee list to see whether the payee name already exists. If it does, do nothing. If it does not, return the new payee name to the decision's result node and create a new payee.

    Image:Creating Collections from other Collections Using External Context

    The above schema fragment shows the Mbr_Rollover_History list within the Member document – ‘PRz_Name’ is an attribute of Payee. We are creating a Payee list from the set of all Member Rollover Payees.

        Image:Creating Collections from other Collections Using External Context

    The above schema fragment shows the Payee list within the Control document – ‘PayeeName’ is an attribute of Payee. This is the list we are creating.

    Decision Model for External Context

    The above decision model fragment shows the decision group ‘Cycle through Rollovers’ with context on the multi-valued ‘Mbr_Rollover_History’ element - this is the first list. The @PayeeName decision has context on the Payee List - this is the second list. The ‘Cycle through Rollovers’ decision group will automatically cycle through all elements in the collection of rollovers, executing the @PayeeName decision for each rollover element. For each rollover processed by the ‘Cycle through Rollovers’ decision group the @PayeeName decision will cycle through all Payee's in the Payee list, and will create a new Payee if required. When it needs to read the rollover PRz_Name, the @PayeeName formula will access the rollover cursor (i.e. the currently indexed node) using the ExternalContext operator. The decision @PayeeName has the mauve color code for ‘Always Create’.  

    Note that the decision ‘action’ type is ‘Always Create’; this means that when the decision terminates normally, it will create its context node, and will always create a new parent context in the list of Payees.

    Image

    This is the formula for the @PayeeName decision. The ‘AnyNodeTrue’  operator creates a new context on the multi-valued Payee node and iterates over it. This fomula is executed by its decision for each rollover node. It checks the rollover ‘PRz_Name’ (accessed via the ExternalContext operator) against every PayeeName.

    There are three contexts in play:

    • The @PayeeName formula context is controlled by the AnyNodeTrue operator.
    • The @PayeeName decision has context within, but at the end of, the Payee element list.
    • The PRz_Name has context determined by the ‘Cycle through Rollovers’ decision group. To access this last context we use the ExternalContext operator. In order to use ExternalContext, the list for which context is required must be the subject of a decision group ancestor of the executing decision. Multiple levels of external context can be used by plugging together multiple ExternalContext operators – each instance of the operator steps up the tree one more context.
    The formula can be paraphrased as saying that if any payee name in the member history collection already exists in the payee list, then do nothing; otherwise, return a new payee name to be added to the payee list. The 'logical english' that is generated for this formula is as follows (the ExternalContext context shifts are identified by the square brackets).