Thursday, June 19, 2008

OBIEE Blocking request based on Criteria

The basis can be found in Oracle Business Intelligence Presentation Services Administration Guide (B31766.pdf)


“ When a user attempts to execute a request that your code blocks, you can display an error message, and the request will not be 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 request. The function can return True if the request is not blocked, or False or a message if the request is blocked. If a message or a value other than False is returned, the message is displayed in a popup window. In either case, the query is blocked.”


Since the documentation on this subject is guiding you in the wrong direction, I toke upon myself to make a step by step instruction.

Step 1: in .. \OracleBI\web\msgdb create a customMessages folder if it not already there:


Step 2: in \OracleBI\web\msgdb\customMessages create an XML file named : qbCriteria.xml (The name is arbitrary, the content isn’t !!!)


Step 3:
Enter the following XML into the 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 language="javascript" src="fmap:myblocking.js" /}
{ /HTML}
{ /WebMessage}
{ /WebMessageTable}
{ /WebMessageTables}

Replace the { and }
Save the file!

In …OracleBI\web\app\res\b_mozilla (this is wrong in the OBIEE documentation) make a new text file called myblocking.js




Enter the following Script:

// This is a blocking function. It makes sure users pick what I want them to.
function validateAnalysisCriteria(analysisXml)
{
// Create the helper object
var tValidator = new CriteriaValidator(analysisXml);
// Validation Logic
if (tValidator.getSubjectArea() != "Paint")
return "Why don't you try Paint?";
if (!tValidator.dependentColumnExists("Markets","Region","Markets","District"))
{
// If validation script notifies user, then return false
alert("Region and District go so well together, don't you think?");
return false;
}
if (!tValidator.dependentColumnExists("Sales Measures","","Periods","Year"))
return "You picked a measure so pick Year!";
if (!tValidator.filterExists("Sales Measures","Dollars"))
return "Why don't you filter on Dollars?";
if (!tValidator.dependentFilterExists("Markets","Market","Markets"))
return "Since you're showing specific Markets, please filter the markets.";
var n = tValidator.filterCount("Markets","Region");
if ((n <= 0) (n > 3))
return "Please select 3 or fewer specific Regions";
return true;
}

save the file:

the name myblocking.js is seemingly hard coded is OBIEE somewhere, I wasn’t able to change it……..

Restart the whole BI-server and play around in the Paint and Paint Exec subject area.

In Paint Exec:

In Paint:



Till Next Time

11 comments:

Ravi said...

John,
I have tried to implement this in Windows OS for OBIEE 10.1.3.3.3, but it did not work. When i try to run a report from answers it displays nothing. Even if i click on results tab with the required fields it is not displaying anything. Can you please let me know what i have done wrong. I have tried to put the myblobking.js in both locations specifed by you and OBIEE Help PDF file and used the same code provided by you fro xml and js files.

John Minkjan said...

@Ravi,

Did you check the XML file?
Did you check the name of you blocking.js ? It's case sensitive.

regards

John

Ravi said...

John,
I have verified and the files are correct. I was able to implement the same in an environment where im using IIS, but gives me error in the environment where I use oc4j for OBI as Web Server. So do i need to make any changes in an environment where I use OBI with Web Logic in UNIX.
Regards,
Ravi

Ravi said...

John,
Even the scripts works only for Paint RPD but not for any custom RPD or Subject Area. Do i need to make any other changes or configurations.

Regards,
Ravi

John Minkjan said...

@Ravi,

You will have to change the tValidator references.

Regards

John

Diptesh said...

Hi John,

I was trying to block request on Dashboard...

Do you have any idea, how to achieve that?

Thanks...

John Minkjan said...

@Diptesh

Not really sure what you are trying to achieve, have look here:
http://obiee101.blogspot.com/2008/08/obiee-hidding-dashboard-sections.html

regards

John

rohini said...

Hello,

I have a Query Blocking rules in place. When I execute saved queries from tree structure on right pane, it invokes blocking rules but when I execute queries from workspace (Left pane) it does not invoke blocking rules.

The query blocking rule is in WebMessage name="kuiCriteriaBlockingScript" under function validateAnalysisCriteria

Any ideas on what I may be missing?

Thanks
RA

John Minkjan said...

@rohini,

What version are you on? Did you raise an SR?

Regards

John

Anonymous said...

John,

You mention:

In …OracleBI\web\app\res\b_mozilla (this is wrong in the OBIEE documentation) make a new text file called myblocking.js

This is wrong? than where should myblocking.js be placed.

I am using 10.1.3.4.1.090414.1900 version.

I have placed my js file at
C:\OracleBI\web\app\res\b_mozilla
C:\OracleBI\oc4j_bi\j2ee\home\applications\analytics\analytics\res\b_mozilla

It still does not work.

I am using Paint.

After implementing the codes and resstarting services, when i test this, by creating a test report and hit display results, it just sits there, no popups no messages.

Please help.

Bond

Anonymous said...

we have been struggling to acheive this from last two days but not with much Success. Well didnt give up on this.
The solution

function validateAnalysisCriteria(analysisXml)
{
// Create the helper object
var tValidator = new CriteriaValidator(analysisXml);
// Validation Logic
if (tValidator.getSubjectArea() != "Paint")
return "Why don't you try Paint?";
if (!tValidator.dependentColumnExists("Markets","Region","Markets","District"))
{
// If validation script notifies user, then return false
alert("Region and District go so well together, don't you think?");
return false;
}
if (!tValidator.dependentColumnExists("Sales Measures","","Periods","Year"))
return "You picked a measure so pick Year!";
if (!tValidator.filterExists("Sales Measures","Dollars"))
return "Why don't you filter on Dollars?";
if (!tValidator.dependentFilterExists("Markets","Market","Markets"))
return "Since you're showing specific Markets, please filter the markets.";
var n = tValidator.filterCount("Markets","Region");
if ((n <= 0) || (n > 3))
return "Please select 3 or fewer specific Regions";
return true;
}
Paste this java script in the location C:\OracleBIData\web\res please observe not oracle bi but in oracle bi data.
and xml file in C:\OracleBIData\web\msgdb\l_en\customMessages. Copy the l_en folder from C:\OracleBI\web\msgdb\l_en.
you might want to check the xml file carefully.
{?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 language="javascript" src="c:\oraclebidata\web\res\myblocking.js" /}
{/HTML}
{/WebMessage}
{/WebMessageTable}
{/WebMessageTables}
instead of giving fmap the exact location of java script has been given. Please note that. fmap might not work. Restart your bi,presentation and oc4j. and you should be all set.
good luck.