In the Sample App v305 environment (you can download the VM from Oracle Business Intelligence Samples), dashboard 4.2 you can see the following behavior:
When you click on the value, you open a popup windows that accepts parameter:
Lets check out how its done and then improve it a little.
What do I want to improve? If you are using this code many times, you are left with many popup windows at the background. What I want to add is a functionality that closes the popup window after 60 seconds automatically (you want other timing or other logic... you are welcome to change the code).
What do I want to improve? If you are using this code many times, you are left with many popup windows at the background. What I want to add is a functionality that closes the popup window after 60 seconds automatically (you want other timing or other logic... you are welcome to change the code).
What we have here are 2 parts:
1. Some JavaScript code available as "Invoke browser script" Action.
2. Using that code as Action in one analysis and call another, while passing parameters.
Since I'm not a javascript expert, I decided to steal the code from the Oracle Demo. Unlike other stealing cases (like the rude bloggers that copy/paste my posts from time to time) the Oracle Sample App was created for us to steal from it.
Lets start with the javascript.
In your OBIEE installation at the following location:
MWHOME\user_projects\domains\bifoundation_domain\servers\bi_server1\tmp\_WL_user\analytics_11.1.1\CHANGING_NAME\war\res\b_mozilla\actions (in my case it was D:\or\MWHOME\user_projects\domains\bifoundation_domain\servers\bi_server1\tmp\_WL_user\analytics_11.1.1\7dezjl\war\res\b_mozilla\actions), you will find the file UserScripts.js.
Back it up before you do anything.
Now I copy / pasted from the same file in the Samples VM the following code:
USERSCRIPT.displayPopupWindow = function(aParams){
var strURL,w,h,scroll;
for( args in aParams )
{
var argName = args;
var argValue = aParams[argName];
if(argName=="url"){
strURL = aParams[argName];
} if(argName=="width"){
w = aParams[argName];
} if(argName=="height"){
h = aParams[argName];
} if(argName=="scroll"){
scroll = aParams[argName];
} else {
argName = "@{" + argName + "}";
strURL = strURL.replace(argName,argValue);
}
}
var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
var settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=0,
toolbar=0,menubar=0,location=0,status=0';
popupWindow = window.open(strURL,'',settings);
popupWindow.show();
};
USERSCRIPT.displayPopupWindow.publish =
{
parameters :
[
new USERSCRIPT.parameter( 'url', 'Enter URL', 'www.oracle.com' ),
new USERSCRIPT.parameter( 'width', 'Width of popup window', '500' ),
new USERSCRIPT.parameter( 'height', 'Height of popup window', '500' ),
new USERSCRIPT.parameter( 'scroll', 'Include scroll bars?', 'no' ),
new USERSCRIPT.parameter( 'p1', 'Enter value for Param 1', '' ),
new USERSCRIPT.parameter( 'p2', 'Enter value for Param 2', '' )
]
};
Since, as I said, I want the popup window to close automatically after 60 seconds, I added the line: setTimeout(function(){popupWindow.close();},60000);
So the result is:
USERSCRIPT.displayPopupWindow = function(aParams){
var strURL,w,h,scroll;
for( args in aParams )
{
var argName = args;
var argValue = aParams[argName];
if(argName=="url"){
strURL = aParams[argName];
} if(argName=="width"){
w = aParams[argName];
} if(argName=="height"){
h = aParams[argName];
} if(argName=="scroll"){
scroll = aParams[argName];
} else {
argName = "@{" + argName + "}";
strURL = strURL.replace(argName,argValue);
}
}
var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
var settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=0,
toolbar=0,menubar=0,location=0,status=0';
popupWindow = window.open(strURL,'',settings);
setTimeout(function(){popupWindow.close();},60000);
popupWindow.show();
};
USERSCRIPT.displayPopupWindow.publish =
{
parameters :
[
new USERSCRIPT.parameter( 'url', 'Enter URL', 'www.oracle.com' ),
new USERSCRIPT.parameter( 'width', 'Width of popup window', '500' ),
new USERSCRIPT.parameter( 'height', 'Height of popup window', '500' ),
new USERSCRIPT.parameter( 'scroll', 'Include scroll bars?', 'no' ),
new USERSCRIPT.parameter( 'p1', 'Enter value for Param 1', '' ),
new USERSCRIPT.parameter( 'p2', 'Enter value for Param 2', '' )
]
};
Please be very careful if you copy paste this code from this blog, especially with the " character. It might be better to get it from the UserScripts.js file downloadable from here. In this file I copied additional parts from the VM (be careful with the file as well, I haven't tested it all yet).
};
USERSCRIPT.displayPopupWindow.publish =
{
parameters :
[
new USERSCRIPT.parameter( 'url', 'Enter URL', 'www.oracle.com' ),
new USERSCRIPT.parameter( 'width', 'Width of popup window', '500' ),
new USERSCRIPT.parameter( 'height', 'Height of popup window', '500' ),
new USERSCRIPT.parameter( 'scroll', 'Include scroll bars?', 'no' ),
new USERSCRIPT.parameter( 'p1', 'Enter value for Param 1', '' ),
new USERSCRIPT.parameter( 'p2', 'Enter value for Param 2', '' )
]
};
Please be very careful if you copy paste this code from this blog, especially with the " character. It might be better to get it from the UserScripts.js file downloadable from here. In this file I copied additional parts from the VM (be careful with the file as well, I haven't tested it all yet).
To have the javascript working you need to reset the BI Server and more important, clear the browser cache. Javascipts is exactly the type of thing the browsers tend to cache.
Next you should be able to see the diplayPopupWindow in your "Invoke browser script" Actions.
In the second part we will use this action.
On my OBIEE I created 2 analysis. Named Parent and Child.
The child analysis, had 2 relevant columns with "Is Prompted" filters ("Per Name Month" and "Products").
In the Parent analysis I had a Revenue column with the following Interaction.
After I selected the scripts from the browse window, I had the parameters ready:
I marked all parameters Hidden, to avoid interaction with user.
I filled the first parameter, the URL:
saw.dll?Go&Action=print&path=%2Fusers%2Fweblogic%2Fpoptest%2Fchild&col1="Time"."Per Name Month"&val1="@{p1}"&op1=eq&col2="Products"."Product"&val2="@{p2}"&op2=eq
The rest were easy:
Window height (650 in my case)
Window Length (500)
Do I want scrolling in the window? (no)
2 columns that I pass as parameters in the URL (select column Value a seen bellow and the column you want)
You might ask, what if it's not 2 parameters I want? Then modify the script.
That's it.
I did same thing, but I can not able to see the function that I added under ny UserScripts.js, I restart my server even the admin server and I clear my cache.
ReplyDeletePlease suggest what are necessary steps I need to follow to be able to see that I added under in UserScript.js
Syed, I did the following:
Delete1. Downloaded the file from the link in the post.
2. Moved the existing file to another location and placed the downloaded file in the folder specified in the post (I had the default one, before).
3. Started the OBIEE on my WIN7 computer.
4. Cleared the browser cache (Ctrl+Shift+del) well and entered OBIEE.
5. I can now see the full list (10 lines) in Invoke Browser Script / Browse. In another browser without the cache cleaning process I can see only the default -3 lines list.
Regards,
Boris
Hi Boris,
DeleteThe file from the link is not getting downloaded. The webpage itself doesn't come up. Is there any other location from where I can download the file?
Sorry, that server is down, and I don't have the file. The blog should do, just consider retyping the ".
DeleteHi,
ReplyDeleteHow can you pass presentation server variables here?
This comment has been removed by the author.
ReplyDeletehow filter data in page child by query string???
ReplyDeleteIt is passed in the parameters of the action (selecting Column name selects the columns in parent analysis, the values of those columns are passed as parameters to the script/pop up).
DeleteUseful article. Thanks :)
ReplyDeleteMarvelous, what a blog it is! This blog presents helpful information to us, keep it up.
ReplyDelete