The bxp looping engine in Keystats allows a creator of a Key Stats report to ensure that the report he/she creates created 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 Keystats report by enabling the creation of 100% dynamic and customisable reports, that could meet any user needsmany different requirements. When creating a Key Stats Keystats 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 Keystat 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 Keystats module handles the same as the conventional ''FOR loop'', i.e. Loop the following for X times.
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 StatsKeystats, Internal Loops, or even the entire Key Stats Keystats 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 StatsKeystats, Internal Loops or even the entire Key Stats report.
<syntaxhighlight lang="html4strict">
When creating a Graphic Key StatsKeystats, perform the same looping options as above, but instead of adding the looping syntax to the Key Stat Keystat Tab, the syntax gets added to the actual KeyStat Keystat that is generating the graphic. The same Key Stat Keystat syntax is used for both the Outer and Internal Loops.
<syntaxhighlight lang="html4strict">
== Dynamic Replacements ==
The Key Stats Keystats 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%91%91LoopCount]] -- This gets replaced with the current loop count for Outer loops 2) [[Internal_LoopCount%91%91Internal_LoopCount]] -- This gets replaced with the current loop count for Internal loops
=== Dynamic Replacements In Use ===
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 following syntax (but make sure it is the very last parameter passed to the key stat:
// * 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
</syntaxhighlight>
As a Key Stat Keystat can have multiple parameter parameters to replace we need to , specify were where in out the statement to perform the replacement, to . To do this we need to add a specific key word to the places,in the SQL statement that we want need to replacebe replaced. This key word is ''[[intParamAdd]]'', when . When the Key Stats Keystats engine sees this it will replace it with the required value, as outlined above.
<syntaxhighlight lang="MySQL">
// * 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
After the replacement has been calculated we have there is a final option that can be used, this . 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.
<syntaxhighlight lang="MySQL">
// * 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
</syntaxhighlight>
[[Category:Module Specific:KeyStats]]