Configuring Fonts for Graphs

18-14 System Administrators Guide for Oracle Business Intelligence Enterprise Edition ■ Section 18.5.4, Validation Helper Functions

18.5.1 Storing JavaScript Files

This section explains how to use JavaScript to check conditions and validate analyses. You write your own JavaScript programs for performing these tasks and other similar ones. Oracle BI EE does not install any JavaScript programs. As you write JavaScript programs, you can store them in the following directory: ORACLE_ INSTANCE\bifoundation\OracleBIPresentationServicesComponent\coreapplication_ obipsn\analyticsRes To place JavaScript programs in a directory other than this one, then you can do so, if you specify the full path name in the code that calls the program. For example, you can use code such as the following: script type=textjavascript src=http:examplemydirmyblocking.js

18.5.2 Blocking Analyses Based on Criteria

When a user attempts to execute an analysis that your code blocks, you can display an error message, and the analysis is not executed. The answerstemplates.xml file includes a message named kuiCriteriaBlockingScript that can be overridden to either define or include JavaScript that defines a validateAnalysisCriteria function. By default, this message contains a function that always returns True. Answers calls your validateAnalysisCriteria function when the user tries to execute the analysis. The function can return True if the analysis is not blocked, or False, or a message if the analysis is blocked. If a message or a value other than False is returned, then the message is displayed in a popup window. In either case, the query is blocked. The following code example shows the blocking of a query. First, place the following XML code in the answerstemplates.xml file. ?xml version=1.0 encoding=utf-8? WebMessageTables xmlns:sawm=com.siebel.analytics.web.messageSystem WebMessageTable system=QueryBlocking table=Messages WebMessage name=kuiCriteriaBlockingScript translate=no HTML script type=textjavascript src=fmap:myblocking.js HTML WebMessage WebMessageTable WebMessageTables This XML code calls a JavaScript program called myblocking.js. Ensure that you place this file in the ORACLE_ INSTANCE\bifoundation\OracleBIPresentationServicesComponent\coreapplication_ obipsn\analyticsRes directory. The following is sample code for the myblocking.js program. This is a blocking function. It ensures that users select what the designer wants them to. function validateAnalysisCriteriaanalysisXml { Create the helper object var tValidator = new CriteriaValidatoranalysisXml; Validation Logic if tValidator.getSubjectArea = Sample Sales return Please try Sample Sales?; Configuring and Managing Analyses and Dashboards 18-15 if tValidator.dependentColumnExistsMarkets,Region,Markets,District { If validation script notifies user, then return false alertRegion and District are well suited, do you think?; return false; } if tValidator.dependentColumnExistsSales Measures,,Periods,Year return You selected a measure so pick Year; if tValidator.filterExistsSales Measures,Dollars return Maybe filter on Dollars?; if tValidator.dependentFilterExistsMarkets,Market,Markets return Since you are showing specific Markets, filter the markets.; var n = tValidator.filterCountMarkets,Region; if n = 0 || n 3 return Select 3 or fewer specific Regions; return true; } If you do not override the function using the template as described previously, or if the function returns anything other than False, then the criteria is considered to be valid and the analysis is issued. The criteria is validated using this same mechanism for preview and save operations as well. After making this change, either stop and restart the server for Oracle BI Presentation Services, or click the Reload Files and Metadata link on the Administration page.

18.5.3 Blocking Analyses Based on Formula

Answers provides a hook that lets you incorporate a JavaScript validation function that is called from Answers when a content designer enters or modifies a column formula. If the call fails and returns a message, then 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 Document Object Model DOM manually. The DOM is a way of describing the internal browser representation of the HTML UI page that is currently being displayed in Answers. For more information about the helper functions, see Section 18.5.4, 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 content designer. If the function returns True, then the formula is accepted. If the function returns False, then 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 content designer has the option to click OK to ignore the error. To display your own alert and allow the content designer 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 a 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