Siebel Analytics Web Administration Guide > Administering Siebel Answers > Blocking Requests in Siebel Answers >

Blocking Requests Based on Formula


Siebel Answers provides a hook to create and incorporate a JavaScript validation function that is called from Siebel Answers when a user enters or modifies a column formula. If the call fails and returns a message, Siebel Answers displays the message and cancels the operation. Additionally, helper functions are available so the query blocking function can check for filters, columns, and so on, rather than traversing the DOM manually. For more information on the helper functions, read Validation Helper Functions.

The criteriatemplates.xml file includes a message named kuiFormulaBlockingScript that can be overridden to include JavaScript that defines a validateAnalysisFormula function. By default, this message contains a function that always returns True.

Siebel Answers calls validateAnalysisFormula before applying changes made by the user. If the function returns True, the formula is accepted. If the function returns False, the formula is rejected. Otherwise, the return value from the function is displayed in the message area beneath the formula, as it does currently when an invalid formula is entered.

The user has the option to click OK to ignore the error. To display your own alert and allow the user to continue, your function should return True. To block the query, return False or a message. Your function should investigate the formula passed to it using JavaScript string and regular expression techniques for validation.

The following code example shows a sample custom message.

<?xml version="1.0" encoding="utf-8"?>
<WebMessageTables xmlns:sawm="com.siebel.analytics.web.messageSystem">
   <WebMessageTable system="QueryBlocking" table="Messages">

      <WebMessage name="kuiFormulaBlockingScript" translate="no">
         <HTML>
            <script language="javascript" src="fmap:myblocking.js" />
         </HTML>
      </WebMessage>

   </WebMessageTable>
</WebMessageTables>

The following code example shows blocking based on the formula entered.

// This is a formula blocking function. It makes sure the user does not enter an unacceptable formula.
function validateAnalysisFormula(sFormula, sAggRule)
{

   // we don't allow the use of concat || in our formulas
   var concatRe = /\|\|/gi;
   var nConcat = sFormula.search(concatRe);
   if (nConcat >= 0)
      return "You used concatenation (character position " + nConcat + "). That is not allowed.";

   // no case statements please
   var caseRe = /CASE.+END/gi;
   if (sFormula.search(caseRe) >= 0)
      return "Please do not use a case statement.";

   // Check for a function syntax: aggrule(formula) aggrule should not contain a '.'
   var castRe = /^\s*\w+\s*\(.+\)\s*$/gi;
   if (sFormula.search(castRe) >= 0)
      return "Please don't use a function syntax such as RANK() or SUM().";

return true;
}

Siebel Analytics Web Administration Guide