Oracle® Business Intelligence Presentation Services Administration Guide > Administering Oracle BI Answers > Blocking Requests in Answers >

Blocking Requests Based on Formula

Answers provides a hook to create and incorporate a JavaScript validation function that is called from Answers when a user enters or modifies a column formula. If the call fails and returns a message, 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.

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="">
   <WebMessageTable system="QueryBlocking" table="Messages">

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


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 =;
   if (nConcat >= 0)
      return "You used concatenation (character position " + nConcat + "). That is not allowed.";

   // no case statements please
   var caseRe = /CASE.+END/gi;
   if ( >= 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 ( >= 0)
      return "Please don't use a function syntax such as RANK() or SUM().";

return true;

Oracle® Business Intelligence Presentation Services Administration Guide Copyright © 2007, Oracle. All rights reserved.