RuleAPI:Procedural commands/CallProc

From FlexRule Wiki
Jump to: navigation, search


In a procedural engine, multiple procedures can be interlinked. This means that a procedural rule can execute another rule; thus, the context of the parent rule can be shared, and the result can be copied back to the root context. Different scenarios can be managed in several ways.


  1. contextMode
    1. Description: Sets the context for the called procedure
    2. Mandatory: Yes
    3. Types
      1. New: Creates a new context and uses such context for execution; in this case, the variable of the new context must be registered by the Param command
      2. Shared: Uses the current context for execution and the new procedure after finishing the procedure execution; the current execution variable context (of only out-variables) is copied to the original one
  2. resultCopyMode
    1. Description: This attribute is set when the target procedure has variables that need to be accessed via the root executing procedure.
    2. Mandatory: Yes
    3. Types
      1. None: Does not copy
      2. AddOut: Copies out-variables
      3. AddIn: Copies in-variables
      4. AddBoth: Copies both in- and out-variables
  3. return
    1. Description: Sets a value of a parameter as a return value of the operation/call
    2. Mandatory: No
    3. Types: String (name of a parameter

Internal Commands


This command passes a value to the procedure and registers new variables in a new context if required.


This command provides the rule with a source to be loaded and executed. It can be a relative or absolute file path or a RuleSet address. If it is a relative file path, the location is initiated from your application’s execution folder. If it is a RuleSet address, it should be a valid address, and the engine should be initialized using RuleSet overload.


  1. <CallProc contextMode="Shared" resultCopyMode="AddOut" >
  2.    <ProcSource uri="Rules/Ver2/CalculatePriceSubTotal.xml" />
  3.    <!-- 
  4.          When we use contextMode="New" we need to pass the
  5.          required parameter for the target procedure, otherwise
  6.          all of the variables are shared in the main procedure and do
  7.          not need to pass <Param .... />
  9.    <Param name="StarQty" ref="StarQty"/>
  10.    <Param name="GoldQty" ref="GoldQty"/>
  11.    <Param name="SilverQty" ref="SilverQty"/>
  13.   -->
  14.    <Param name="StarQtyDiscount" ref="StarQtyDiscount"/>
  15.    <Param name="GoldQtyDiscount" ref="GoldQtyDiscount"/>
  16.    <Param name="SilverQtyDiscount" ref="SilverQtyDiscount"/>
  18. </CallProc>