User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:adminmanual:businessmappings:decisiontable [2020/07/05 22:48]
a.sinani [Select Dish with Module]
en:adminmanual:businessmappings:decisiontable [2020/08/20 21:06] (current)
joebordes [Default Value]
Line 76: Line 76:
         <​condition>​         <​condition>​
           <​input></​input> ​ <!-- context variable name -->           <​input></​input> ​ <!-- context variable name -->
-          <​preprocess></​preprocess> ​ <!-- optional: if present ​indicates that the input is anexpression ​-->+          <​preprocess></​preprocess> ​ <!-- optional: if present, the result of the expression it contains will be used as the input -->
           <​operation></​operation> ​ <!-- QueryGenerator operators -->           <​operation></​operation> ​ <!-- QueryGenerator operators -->
           <​field></​field> ​ <!-- fieldname of module -->           <​field></​field> ​ <!-- fieldname of module -->
Line 89: Line 89:
 </​decision>​ </​decision>​
 </​code>​ </​code>​
 +
 +<WRAP center round info 80%>
 +To make this type of map easier to construct when we have a large number of input variables, the input variables accept the special value **"​%%__IGNORE__%%"​**. When an input variable is set to this value the whole search on that column will be ignored. This permits us to establish rules that are more generic reducing the repetition of very similar rules.
 +</​WRAP>​
 +
 ===== Hit Policy ===== ===== Hit Policy =====
  
Line 117: Line 122:
 $result = coreBOS_Rule::​evaluate(put your decision map ID or name here, $context); $result = coreBOS_Rule::​evaluate(put your decision map ID or name here, $context);
 </​code>​ </​code>​
 +
 +
 +===== Web service execution =====
 +
 +You can evaluate Decision Maps via the web service endpoint: **cbRule**
 +
 +<code PHP>
 +$context = array(
 + '​guestcount'​ => '​4',​
 + '​season'​ => '​Winter',​
 +);
 +$context = json_encode($context);​
 +$mapid = '​SeasonDish twocolumns';​
 +
 +//sessionId is obtained from loginResult.
 +$params = "​sessionName=$cbSessionID";​
 +$params.= "&​operation=cbRule";​
 +$params.= "&​conditionid="​.urlencode($mapid);​
 +$params.= "&​context="​.urlencode($context);​
 +
 +//Retrieve must be GET Request.
 +$response = $httpc->​fetch_url("​$cbURL?​$params"​);​
 +$dmsg.= debugmsg("​Raw response (json)",​ $response);
 +
 +//decode the json encode response from the server.
 +$jsonResponse = json_decode($response,​ true);
 +$dmsg.= debugmsg("​Webservice response",​ $jsonResponse);​
 +
 +//operation was successful get the token from the response.
 +if($jsonResponse['​success'​]==false) {
 + $dmsg.= debugmsg('​failed:'​.$jsonResponse['​error'​]['​message'​]);​
 + echo 'rule failed!';​
 +} else {
 + echo $jsonResponse['​result'​];​
 +}
 +</​code>​
 +
  
  
Line 288: Line 330:
  
 the possibilities that the implementor has are very big. the possibilities that the implementor has are very big.
 +
 +===== IGNORE Reserved Word =====
  
 Finally, comment on a very important option where you can set the value of any variable in the context to **%%__IGNORE__%%** to have that variable eliminated from the decision. This permits us to create complex rules with many variables where we search on only a few of them at a time. Finally, comment on a very important option where you can set the value of any variable in the context to **%%__IGNORE__%%** to have that variable eliminated from the decision. This permits us to create complex rules with many variables where we search on only a few of them at a time.
  
 +We can also use this special reserved word in the rules table itself to create rules which cover many cases. For example, we could have a table of rules like this:
 +
 +^input1^input2^output^
 +|e1|c1|r1|
 +|%%__IGNORE__%%|c2|r2|
 +|e3|c3|r3|
 +
 +
 +With these rules in place, any decision that has input2==c2 will pass no matter what value is passed in as input1. Note that this can easily cause that more than one rule to pass. If we add a rule to the table above, like this:
 +
 +^input1^input2^output^
 +|e1|c1|r1|
 +|%%__IGNORE__%%|c2|r2|
 +|e2|c2|r2b|
 +|e3|c3|r3|
 +
 +and we pass in the values
 +
 +  - input1=e2
 +  - input2=c2
 +
 +**both r2 and r2b will pass** and be returned, so if we have a hit policy of Unique it will fail and if we have a hit policy of First then the sequence is of utmost importance to get the correct result.
 +
 +===== Default Value =====
  
-==== Preprocess Directive ====+Using the %%__IGNORE__%% reserved word we can implement a default value for our rules. If we define a rule where all the input values are set to %%__IGNORE__%%,​ this rule will pass for all input values. If we set the hit policy of the decision map to First and order the rules in a way that the all %%__IGNORE__%% rule is always the last to be evaluated we accomplish a decision table where any combination of input values that is not explicitly defined will return the values in the all %%__IGNORE__%% rule instead of %%__DoesNotPass__%% 
 +===== Preprocess Directive ​=====
  
 Following the new enhancements,​ we don't have to valorize context variables on the Decision Table map using the Execute Expression Workflow before evaluating the Decision table map. The map will be evaluated on the context of the values that are present on the screen. Following the new enhancements,​ we don't have to valorize context variables on the Decision Table map using the Execute Expression Workflow before evaluating the Decision table map. The map will be evaluated on the context of the values that are present on the screen.
Line 321: Line 390:
 <​condition>​ <​condition>​
  <​input>​guestcount</​input>​ <!-- context variable name -->  <​input>​guestcount</​input>​ <!-- context variable name -->
- <​preprocess>​if season == '​Spring'​ then '​*'​ else guestcount end</​preprocess> ​ <!-- if present sends the expression to the workflow expression system-->​+ <​preprocess>​if ​'$[season]' ​== '​Spring'​ then '​*'​ else '$[guestcount]' ​end</​preprocess> ​ <!-- if present sends the expression to the workflow expression system-->​
  <​operation>​e</​operation>​ <!-- QueryGenerator operators -->  <​operation>​e</​operation>​ <!-- QueryGenerator operators -->
  <​field>​guestcount</​field>​ <!-- fieldname of module -->  <​field>​guestcount</​field>​ <!-- fieldname of module -->
Line 327: Line 396:
  </​code>​  </​code>​
  
-As you can see we are using the preprocess directive. What is inside the preprocess directive will be sent to the workflow system. ​+As you can see we are using the preprocess directive. What is inside the preprocess directive will be sent to the workflow system. 
 So if the season is Spring that valorizes the context variable with the value * and then searches the decision table module for a match. Now, whenever the decision map gets evaluated on a record whose value of the Season field is Spring it will consider the value of Guest Number as * and for our Decision Table module that means that the desired dish is Beef. So if the season is Spring that valorizes the context variable with the value * and then searches the decision table module for a match. Now, whenever the decision map gets evaluated on a record whose value of the Season field is Spring it will consider the value of Guest Number as * and for our Decision Table module that means that the desired dish is Beef.
- 
- 
- 
- 
- 
- 
- 
- 
- 
  
 ===== Select Global Variable Escalation ===== ===== Select Global Variable Escalation =====