Difference between revisions of "Keystats - Looping Engine"

From All n One's bxp software Wixi

Jump to: navigation, search
(Created page with "== Overview == The bxp looping engine allows a creator of a Key Stats report to ensure that the report he/she creates is 100% dynamic i.e not limiting the report to a set nu...")
 
Line 5: Line 5:
 
The looping engine of Key Stats should be used in conjunction with the numerous dynamic replacements that bxp key stats module provides or with the user specified custom replacements.
 
The looping engine of Key Stats should be used in conjunction with the numerous dynamic replacements that bxp key stats module provides or with the user specified custom replacements.
  
The looping engine greatly enhances the reporting ability of any Key Stats report by enabling the creation of 100% dynamic and customisable reports, that could meet any user needs. When creating the a Key Stats Report an using the looping engine, there are two loop types are your disposal: ''Outer Loop'' and ''Internal Loop'', you are able to have as many ''Outer Loops'' in the report as required and also have as many ''Internal Loops'' but every ''Internal Loop'' cannot have another ''Internal Loop'' inside it.
+
The looping engine greatly enhances the reporting ability of any Key Stats report by enabling the creation of 100% dynamic and customisable reports, that could meet any user needs. When creating a Key Stats Report using the looping engine, there are two loop types available: ''Outer Loop'' and ''Internal Loop''. The number of ''Outer Loops'' are as required, same with ''Internal Loops''. However, every ''Internal Loop'' cannot have another ''Internal Loop'' inside of it.
  
  
When adding loops to a Key Stat report, the loops can be added at two levels i.e ''Tab level'' and ''Graphic level''
+
When adding loops to a Key Stat report, the loops can be added at two levels, ''Tab level'' and ''Graphic level''.
  
In coding terms the looping engine of the bxp Key Stats module handles the same as the conventional ''FOR loop'' i.e Loop the following for X times.
+
In coding terms the looping engine of the bxp Key Stats module handles the same as the conventional ''FOR loop'', i.e. Loop the following for X times.
  
  
Line 16: Line 16:
  
  
When creating an Outer Loop in a bxp Key Stats report, there are three required pieces of syntax required:
+
When creating an Outer Loop, there are three pieces of syntax required:
  
  
1) [Loop_Start]  -- This alerts the looping engine of Key Stats to the start of an Outer loop section in the report
+
1) [Loop_Start]  -- This alerts the looping engine to the start of an Outer loop section in the report
  
2) [Loop_End]    -- This alerts the looping engine of Key Stats to the end of an Outer loop section in the report  
+
2) [Loop_End]    -- This alerts the looping engine to the end of an Outer loop section in the report  
  
3) [##X##]         -- This tells the looping engine of key Stats that the contents of the current Outer loop should be looped X times
+
3) [##X##]       -- This tells the looping engine that the contents of the current Outer loop should be looped X times
  
  
Line 38: Line 38:
  
  
Anything in between the Start and End Loop tags will be repeated the set number of times specified, the looped content can be anything: HTML, JavaScript, Key Stats, Internal Loops or even the entire Key Stats report.
+
Anything in between the Start and End Loop tags will be repeated the set number of times specified. The looped content can be anything: HTML, JavaScript, Key Stats, Internal Loops, or even the entire Key Stats report.
  
  
Line 88: Line 88:
  
  
When creating an Outer Loop in a bxp Key Stats report, there are three required pieces of syntax required:
+
When creating an Internal Loop, there are three pieces of syntax required:
  
  
1) [Internal_Loop_Start]  -- This alerts the looping engine of Key Stats to the start of an Internal loop section in the report
+
1) [Internal_Loop_Start]  -- This alerts the looping engine to the start of an Internal loop section in the report
  
2) [Internal_Loop_End]    -- This alerts the looping engine of Key Stats to the end of an Internal loop section in the report  
+
2) [Internal_Loop_End]    -- This alerts the looping engine to the end of an Internal loop section in the report  
  
3) [##X##]         -- This tells the looping engine of key Stats that the contents of the current Internal loop should be looped X times
+
3) [##X##]               -- This tells the looping engine that the contents of the current Internal loop should be looped X times
  
'''* NOTE: ''' There should never be an Internal Loop Inside an Internal Loop, the looping engine of Key Stats will not allow an internal loop to have an internal loop
+
'''* NOTE: ''' There should never be an Internal Loop inside an Internal Loop. The looping engine of Key Stats will not allow an internal loop to have an internal loop
  
  
Line 114: Line 114:
  
  
Anything in between the Start and End Loop tags will be repeated the set number of times specified, the looped content can be anything: HTML, JavaScript, Key Stats, Internal Loops or even the entire Key Stats report.
+
Anything in between the Start and End Loop tags will be repeated the set number of times specified. The looped content can be anything: HTML, JavaScript, Key Stats, Internal Loops or even the entire Key Stats report.
  
 
<syntaxhighlight lang="html4strict">
 
<syntaxhighlight lang="html4strict">
Line 179: Line 179:
  
  
When creating a Graphic Key Stats your are able to perform the same looping options as above, but instead of adding the looping syntax to the Key Stat Tab, the syntax gets added to the actual KeyStat that is rendering the graphic. The same Key Stat syntax is used for both the Outer and Internal Loops.
+
When creating a Graphic Key Stats, perform the same looping options as above, but instead of adding the looping syntax to the Key Stat Tab, the syntax gets added to the actual KeyStat that is generating the graphic. The same Key Stat syntax is used for both the Outer and Internal Loops.
  
 
<syntaxhighlight lang="html4strict">
 
<syntaxhighlight lang="html4strict">
Line 198: Line 198:
 
== Dynamic Replacements ==
 
== Dynamic Replacements ==
  
The Key Stats looping engine of bxp allows for the user of dynamic replacements, these dynamic replacements allow for you to include the current count of the loop. The current loop count can be replaced as many times as required.
+
The Key Stats looping engine allows the use of dynamic replacements. These dynamic replacements include the current count of the loop. The current loop count can be replaced as many times as required.
To perform this replacement the following key words should be used
+
To perform this replacement the following key words should be used:-
  
1) [[LoopCount]] -- This gets replaced with the current loop count for Outer loops  
+
1) [[LoopCount]]         -- This gets replaced with the current loop count for Outer loops  
 
2) [[Internal_LoopCount]] -- This gets replaced with the current loop count for Internal loops  
 
2) [[Internal_LoopCount]] -- This gets replaced with the current loop count for Internal loops  
  
Line 238: Line 238:
  
  
When using the user set dynamic replacements ''keyStatsCustom'', you can modify the parameters inside an SQL statement, for example if you had the statement that counts the number of contacts (CCL's) that happen between two dates but by using the Looping engine th report is set up to  
+
When using the user set dynamic replacements ''keyStatsCustom'', modify the parameters inside an SQL statement. For example, if the statement that counts the number of contacts (CCL's) happens between two dates, by using the Looping engine the report is set up to allow an indefinite amount of dates to be passed in. Instead of creating a different key stat for every iteration of the parameters, use key stats, but replace the parameters that gets passed to it. To use the dynamic replacements for the parameters passed in, use the foollowing syntax (but make sure it is the very last parameter passed to the key stat:
allow an indefinite amount of dates to be passed in. Instead of creating a different key stat for every iteration of the parameters, you can use the one key stats but replace the parameters that gets passed to it. To use the dynamic replacements for the parameters passed in you need to use the foollowing syntax (but make sure it is the very last parameter passed to the key stat:
 
  
  

Revision as of 14:42, 1 May 2015

1 Overview

The bxp looping engine allows a creator of a Key Stats report to ensure that the report he/she creates is 100% dynamic i.e not limiting the report to a set number of time intervals or to a set number of forms. The looping engine of Key Stats should be used in conjunction with the numerous dynamic replacements that bxp key stats module provides or with the user specified custom replacements.

The looping engine greatly enhances the reporting ability of any Key Stats report by enabling the creation of 100% dynamic and customisable reports, that could meet any user needs. When creating a Key Stats Report using the looping engine, there are two loop types available: Outer Loop and Internal Loop. The number of Outer Loops are as required, same with Internal Loops. However, every Internal Loop cannot have another Internal Loop inside of it.


When adding loops to a Key Stat report, the loops can be added at two levels, Tab level and Graphic level.

In coding terms the looping engine of the bxp Key Stats module handles the same as the conventional FOR loop, i.e. Loop the following for X times.


2 Creating an Outer Loop

When creating an Outer Loop, there are three pieces of syntax required:


1) [Loop_Start] -- This alerts the looping engine to the start of an Outer loop section in the report

2) [Loop_End] -- This alerts the looping engine to the end of an Outer loop section in the report

3) [##X##] -- This tells the looping engine that the contents of the current Outer loop should be looped X times


2.1 Outer Loop Structure

       [Loop_Start][##/* LoopCount */##]
        // * Content to Loop and Copy
       [Loop_End]


2.2 Outer Loop In Use Example

Anything in between the Start and End Loop tags will be repeated the set number of times specified. The looped content can be anything: HTML, JavaScript, Key Stats, Internal Loops, or even the entire Key Stats report.


<!--bxp Key Stats Tab Layout-->
       <table id="objExampleTable">
          <tr>
                <td>Heading 1</td>
                <td>Heading 2</td>
                <td>Heading 3</td>
          </tr>
[Loop_Start][##3##]
          <tr>
                <td>Content  1</td>
                <td>Content 2</td>
                <td>Content 3</td>
          </tr>
[Loop_End]  
         </table>    
   
<!--bxp Key Stats Report Output-->
   <table id="objExampleTable">
          <tr>
                <td>Heading 1</td>
                <td>Heading 2</td>
                <td>Heading 3</td>
          </tr>
          <tr>
                <td>Content 1</td>
                <td>Content 2</td>
                <td>Content 3</td>
          </tr> 
          <tr>
                <td>Content 1</td>
                <td>Content 2</td>
                <td>Content 3</td>
          </tr> 
          <tr>
                <td>Content 1</td>
                <td>Content 2</td>
                <td>Content 3</td>
          </tr> 
         </table>


3 Creating an Internal Loop

When creating an Internal Loop, there are three pieces of syntax required:


1) [Internal_Loop_Start] -- This alerts the looping engine to the start of an Internal loop section in the report

2) [Internal_Loop_End] -- This alerts the looping engine to the end of an Internal loop section in the report

3) [##X##] -- This tells the looping engine that the contents of the current Internal loop should be looped X times

* NOTE: There should never be an Internal Loop inside an Internal Loop. The looping engine of Key Stats will not allow an internal loop to have an internal loop


3.1 Internal Loop Structure

       [Internal_Loop_Start][##/* LoopCount */##]
        // * Content to Loop and Copy
       [Internal_Loop_End]


3.2 Internal Loop In Use Example

Anything in between the Start and End Loop tags will be repeated the set number of times specified. The looped content can be anything: HTML, JavaScript, Key Stats, Internal Loops or even the entire Key Stats report.

<!--bxp Key Stats Tab Layout-->
       <table id="objExampleTable">
          <tr>
                <td>Heading 1</td>
                <td>Heading 2</td>
                <td>Heading 3</td>
          </tr>
[Loop_Start][##3##]
    [Internal_Loop_Start][##2##]
          <tr>
                <td>Content  1</td>
                <td>Content 2</td>
                <td>Content 3</td>
          </tr>
    [Internal_Loop_End]
[Loop_End]  
         </table>    
   
<!--bxp Key Stats Report Output-->
   <table id="objExampleTable">
          <tr>
                <td>Heading 1</td>
                <td>Heading 2</td>
                <td>Heading 3</td>
          </tr>
          <tr>
                <td>Content 1</td>
                <td>Content 2</td>
                <td>Content 3</td>
          </tr> 
          <tr>
                <td>Content 1</td>
                <td>Content 2</td>
                <td>Content 3</td>
          </tr> 
          <tr>
                <td>Content 1</td>
                <td>Content 2</td>
                <td>Content 3</td>
          </tr> 
          <tr>
                <td>Content 1</td>
                <td>Content 2</td>
                <td>Content 3</td>
          </tr> 
          <tr>
                <td>Content 1</td>
                <td>Content 2</td>
                <td>Content 3</td>
          </tr> 
          <tr>
                <td>Content 1</td>
                <td>Content 2</td>
                <td>Content 3</td>
          </tr> 
         </table>

4 Key Stat Graphic Looping

When creating a Graphic Key Stats, perform the same looping options as above, but instead of adding the looping syntax to the Key Stat Tab, the syntax gets added to the actual KeyStat that is generating the graphic. The same Key Stat syntax is used for both the Outer and Internal Loops.

<!--bxp Key Stats Outer Loop-->
       [Loop_Start][##/* LoopCount */##]
        // * Content to Loop and Copy
       [Loop_End]

<!--bxp Key Stats Internal Loop-->
       [Internal_Loop_Start][##/* LoopCount */##]
        // * Content to Loop and Copy
       [Internal_Loop_End]


5 Dynamic Replacements

The Key Stats looping engine allows the use of dynamic replacements. These dynamic replacements include the current count of the loop. The current loop count can be replaced as many times as required. To perform this replacement the following key words should be used:-

1) LoopCount -- This gets replaced with the current loop count for Outer loops 2) Internal_LoopCount -- This gets replaced with the current loop count for Internal loops

5.1 Dynamic Replacements In Use

<!--bxp Key Stats Outer Loop-->
       [Loop_Start][##3##]
            Current Loop Count: [[LoopCount]]
       [Loop_End]

<!--Output-->
       Current Loop Count: 1
       Current Loop Count: 2
       Current Loop Count: 3

<!--bxp Key Stats Internal Loop-->
       [Loop_Start][##3##]
           [Internal_Loop_Start][##2##]
              Current Loop Count: Outer:[[LoopCount]] || Internal: [[Internal_LoopCount]]
           [Internal_Loop_End]
       [Loop_End] 

<!--Output-->
       Current Loop Count: Outer: 1 || Internal: 1
       Current Loop Count: Outer: 1 || Internal: 2
       Current Loop Count: Outer: 2 || Internal: 1
       Current Loop Count: Outer: 2 || Internal: 2
       Current Loop Count: Outer: 3 || Internal: 1
       Current Loop Count: Outer: 3 || Internal: 2


5.2 Dynamic Parameter Replacements

When using the user set dynamic replacements keyStatsCustom, modify the parameters inside an SQL statement. For example, if the statement that counts the number of contacts (CCL's) happens between two dates, by using the Looping engine the report is set up to allow an indefinite amount of dates to be passed in. Instead of creating a different key stat for every iteration of the parameters, use key stats, but replace the parameters that gets passed to it. To use the dynamic replacements for the parameters passed in, use the foollowing syntax (but make sure it is the very last parameter passed to the key stat:


// * Structure
[[intParamAdd:/*Start Position*/;/*Number to Add*/;/*Number to subtract*/]]

// * Examples
[[intParamAdd:1;2;0]] --> Will replace in the SQl statement as 3
[[intParamAdd:3;0;2]] --> Will replace in the SQl statement as 1
[[intParamAdd:[[LoopCount]];2;0]] --> Will replace in the SQl statement as the current Outer loop count +2
[[intParamAdd:[[Internal_LoopCount]];2;0]] --> Will replace in the SQl statement as the current Internal loop count +2


As a Key Stat can have multiple parameter to replace we need to specify were in out statement to perform the replacement, to do this we need to add a specific key word to the places, in the SQL statement that we want to replace. This key word is intParamAdd, when the Key Stats engine sees this it will replace it with the required value, as outlined above.


// * Replacement Syntax -> [[intParamAdd:1;2;0]] --> Replace [[intParamAdd]] with 3

// * SQL Statement before replacement 

SELECT COUNT(intCCL_292_Id) FROM CCL_292 
WHERE dteCCL_292_EndDateTime >= '--parameter[[intParamAdd]]-- 00:00:00' 
AND 
dteCCL_292_EndDateTime <= '--parameter[[intParamAdd]]-- 00:00:00';

// * SQL Statement before replacement 

SELECT COUNT(intCCL_292_Id) FROM CCL_292 
WHERE dteCCL_292_EndDateTime >= '--parameter3-- 00:00:00' 
AND 
dteCCL_292_EndDateTime <= '--parameter3-- 00:00:00';


After the replacement has been calculated we have a final option that can be used, this option allows a key stat to further add to the number generated by the above examples. To use this functionality we modify the key word intParamAdd (outlined above), to be intParamAdd:X. Replace X with the number you want to add to the dynamic parameter replacement already generated


// * Replacement Syntax -> [[intParamAdd:1;2;0]] --> Replace [[intParamAdd]] with 3

// * SQL Statement before replacement 

SELECT COUNT(intCCL_292_Id) FROM CCL_292 
WHERE dteCCL_292_EndDateTime >= '--parameter[[intParamAdd:0]]-- 00:00:00' 
AND 
dteCCL_292_EndDateTime <= '--parameter[[intParamAdd:1]]-- 00:00:00';

// * SQL Statement before replacement 

SELECT COUNT(intCCL_292_Id) FROM CCL_292 
WHERE dteCCL_292_EndDateTime >= '--parameter3-- 00:00:00' 
AND 
dteCCL_292_EndDateTime <= '--parameter4-- 00:00:00';