Showing posts with label Button. Show all posts
Showing posts with label Button. Show all posts

Clear button for Default Prompts

Many a times we come across a requirement to provide the users with a button on the Dashboard which will clear the values selected in Prompt. We can do this by a bit a scripting, lets see how we can achive this.
To achive this first we need to create a button and then call a function on that button click which clears the values selected in the prompt.
  • Edit the dashboard page on which we have to place this button.
  • Then pull the Text box from the Dashboards Objects to the desired Section as shown below.
                                               
  • Then copy the below mentioned script in that text box and preview.
“<div><a href=”#” onclick=”return PersonalizationEditor.removeDefaultSelection(false)”>Clear Filter</a></div>”

In the above script the minibuttonOn creates a button and the onclick is an event which clears the default selection on the click of this button. Also, dont forget to remove the ” ” from the above code.
                                         
Now, save this page and clear the default selections on button press… :)

Change ‘Go’ Button Name of OBIEE Dashboard Prompt

Today one question here.  How to change OBIEE dashboard prompt ‘Go’ button Name.
By default, prompt button name will appear as follows:
Go Button
Now Button Name Go has to change to desired Name
  • Navigate to {OracleBIDir}:\oraclebi\web\msgdb\l_en\messages
  • Open globalfiltermessages.xml file (before opening this file, you better take backup of this file)
  • Locate the following text

<WebMessage name="kmsgGFPGo"><TEXT>Go</TEXT></WebMessage>

  • Edit the text ‘Go’ to your desired text.
  • Here I am editing it to ‘Confirm’

<WebMessage name="kmsgGFPGo"><TEXT>Confirm</TEXT></WebMessage>

  • Save the changes to file
  • Restart Presentation service
See the change in text of dashboard prompt Go button, now it’s changed to Confirm button

Confrm

Adding Clear My Filter Link To A Dashboard Page


Current OBIEE Dashboard prompts selections and clearing the selected default is little cubersome.
In some situations it helps to clear the selected prompts and start-over. For that there is a “Clear my Selection” option available in the Page Option.
Sometimes it may also be useful to explicitly put an HTML link just next to the prompts so that it is easily reachable by a novice Dashboard user.
This can be easily accomplished by using a little HTML Text block on the page and put following HTML in the Text block that contains HTML markup

Required Field Validation: Addition to the Global “Go” Button


I have been asked to create custom functionality whereby certain dashboard prompts are required, and the user should not be able to continue until all required fields are selected before they can query.  So I ventured out and created the following script below to do just that.  This script is in addition to the ‘Global’ Go button, or what I referred to in a previous post as the ‘Custom’ Go button.  What this script does is allow the developer to specify which prompt fields they would like to be required.  If any of the fields are not populated by the user an alert/warning box will popup specifying which fields are required in which they did not populate.  This is done in one alert window instead of multiple in order to not be annoying and done correctly.  The rest of the javascript which pulls the data and posts to the presentation server will not be fired, thus the request is blocked until all required fields are populated.
The script is here and the description/breakdown follows:
<script> function GlobalGo(){
try{
var aElm = document.getElementsByTagName(‘table’);
var tTableArray = new Array();
var k = 0;
//Required Field validation variables
var aSpanElm = document.getElementsByTagName(‘span’);
var aReqFields = new Array();
var oneTimeValExists = ‘N’;
//var oneXXXValExists = ‘N’;
var sCaption;
var errMsg = ”;
var i = 0;
var aDivElm = document.getElementsByTagName(‘div’);
var scopeId;
var scopeIndex;
var sViewId;
//BEGIN ********** DEVELOPER(s): Add Required Fields here
aReqFields[0] = ‘Brand’;
aReqFields[1] = ‘Region’;
//END **********
//Get Captions and Controls to check for required fields/values
for(var a=0; a<aSpanElm.length; a++){
//Get Caption
if(aSpanElm[a].className==’GFPCaption’){
sCaption = aSpanElm[a].firstChild.data;
}
//Check if required value exists
if(aSpanElm[a].className==’GFPControl’){
var aInput = aSpanElm[a].getElementsByTagName(‘input’); // multi-select and text boxes
var aOption = aSpanElm[a].getElementsByTagName(‘option’);  // dropdown
//Check if a required field
for(var b=0; b<aReqFields.length; b++){
if(sCaption==aReqFields[b]){
var hasValue = ‘N’;
//Check if multi-select or text box with caption has value
for(var c=0; c<aInput.length; c++){
if(aInput[c].value.length > 0){
hasValue = ‘Y’;
}
}
//Check if dropdown with caption has value
for(var c=0; c<aOption.length; c++){
if(aOption[c].selected && aOption[c].value.trim().length > 0){
hasValue = ‘Y’;
}
}
//if Value does not exists add to errMsg
if(hasValue==’N'){errMsg = errMsg+’* ‘ + aReqFields[b] +’ is a Required Field!\n’;}
}
} //EndFor required Fields
//BEGIN ********** DEVELOPER(s): Add Time Fields here
//check if time field
if(sCaption==’Fiscal Period’ || sCaption==’Fiscal Week’ || sCaption==’Dates’|| sCaption==’Year’){
for(var c=0; c<aInput.length; c++){
if(aInput[c].value.trim().length > 0){
oneTimeValExists = ‘Y’;
}
}
} //Endif check time field
//END **********
//BEGIN ********** DEVELOPER(s): This is template check for ‘OR’ed fields or (At Least one)
//check if time field
//if(sCaption==’Caption1′ || sCaption==’Caption2′ || sCaption==’Caption3′){
//  for(var c=0; c<aInput.length; c++){
//
//    if(aInput[c].value.trim().length > 0){
//      {Need to add one time exists variable here} = ‘Y’;
//    }
//  }
//} //Endif field
//END **********
} //Endif GFPControl
} //EndFor Caption and Controls
if(oneTimeValExists==’N'){errMsg = ‘* At least one time field is Required!\n’+errMsg;}
//{Add same if block above for each ‘At least’ that you created with errmsg}
if(errMsg != ”){
alert(errMsg);
return;
}
for(var i=0; i<aElm.length; i++){
if(aElm[i].className==’GFPBox’){
tTableArray[k] = document.getElementById(aElm[i].id);
k++;
}
} //EndFor Get Prompt Values to send in Post
//Get the sViewId in order to set the pages prompt scope
 for(var f=0; f<aDivElm.length; f++){
   scopeId = aDivElm[f].id;
   scopeIndex = scopeId.indexOf(“Scope”);
   if(scopeIndex != -1){
      sViewId = scopeId.substring(0, scopeIndex);
      //alert(sViewId);
      break;
   }
 }
GFPDoFilters_samvi(sViewId, tTableArray, true);
}
catch(e){alert(‘XXX ‘ + e);}
}
String.prototype.trim = function() {
return this.replace(/^\s*|\s*$/, “”);
}
</script>
<div align=”left”><a href=”#” onclick=”javascript:GlobalGo();”>Go</a></div>
<div align=”left”><a href=”#” onclick=”return
PersonalizationEditor.removeDefaultSelection(false) “>Clear</a></div>
Here are the notes:
  • The section in red: This is where the developer will add the required fields into the array.  Each field added needs to increment the array index or it will over write.  The names put in the required field area are the Dashboard prompt captions.
  • The sections in blue: This section is for the time field validation.  This checks that at least one time field is populated with data.  It also highlights the errMsg used.
  • The sections in purple: This is where a developer can use as a template to create the scenario like time where ‘at least’ one field needs to be used.
  • The sections in green: This is the additional code which sets the prompts’ scope for the page to the first prompt’s scope.  So if the first prompt’s scope is page, all the prompts for the entire page will share the same scope else the entire pages prompts use dashboard scope.
Here is a screen shot of it working within SampleSales.  One of the required fields is selected (Brand).  And as you can see the alert is shown signifying to the user that ‘at least one time field’ and ‘Region’ are required.  The report is not fired for these prompts until all required validation is met.
Required Field Message
Required Field Message
Until next time…I am currently working on script to stop the dashboard page from firing off report queries on entry.  Almost complete this should be added shortly.
-Frank

Custom “Go” Button for vertical Dashboard Prompts


I was requested the other day for a custom job within OBIEE. The request was for an extra “Go” button which would be placed on top of a vertical dashboard prompt. The reason being was that the vertical dashboard prompt was long enough in which it warranted everyone to scroll down in order to press the “Go” button ( which comes implicitly with dashboard prompts at the end of each dashboard prompt.) Since this involved extra work for the users (scrolling), they would like it also at the top of each prompt.
Easy enough, I said fine no problem. This should be easy, just look at the page’s source code and copy the HTML code along with the call to the javascript function and create it via the “Text” dashboard object.
Easier said then done. The javascript call needed table id’s which are not static, but dynamic for each rendering of the page. So I went out searching for the source code or template used for the dashboard pages which generates this so that I could mimic and add what I needed. Not that simple. I then came across a solution, something similar in which I could use to modify for my needs. This was from a Mr. Sunil Ranka via his blog here:  http://sranka.wordpress.com/2008/11/09/how-to-replace-multi-go-button-prompt-by-one/
I used the last two scripts along with the globalFilterPrompt.js changes.  The other changes I did not need, since they are for hiding the dashboard prompt(s) implicit “Go” buttons and I still wanted to show ours.  Now it seems easy, but had problems which took me a while to figure out.  By copy and pasting from his web blog the code snippets will come over with special chars which will result in erratic behavior or errors on page.  So I just needed to remove them which I did so by manually typing the code.  Now I did this so that I could read and understand what he was doing instead of just copy and pasting and not fully understanding what was being done.  Below  I have the two code changes with the results.  I used the sampleSales RPD as my testing ground so the vertical dashboard prompts are not what I am truly using it for.  The target environment has only 1 dashboard prompt, aligned vertically with over a dozen multi-selects and/or drop downs which renders and takes over a page.  The new “Go” which I created is a global submit button, in that it takes all dashboard prompts filter entries and submits them.  The original implicit ones takes only those entries that belong to it dashboard prompt.  Hope that makes sense!
Well first thing was to use the new function for the globalfilterprompt.js.  This javascript file is in two locations: \OracleBI\oc4j_bi\j2ee\home\applications\analytics\analytics\res\b_mozilla\prompts  and \OracleBI\web\app\res\b_mozilla\prompts.  The difference is really what you are using for your web server.  If using OC4J then you would use the first else use the second.  To be safe and redundant you could put in both locations.  Anyways the function to add is the following.  This is taken straight from Mr. Sunil Ranka’s page.  So lets thank him for the work as it helped tremendously.
Append the following script to the js file.
function GFPDoFilters_samvi(sViewID, tTable, bGFPReloadInline){
// RIE: calling GFPDoFilters in preview mode
// doesn’t do anything so we are going to just return
if(sViewID==ksGFPStatePath)
return;
var tExpr = XUICreateElement(saw.xml.kSawxNamespace, ‘expr’);
tExpr.setAttribute(“xsi:type”, “sawx:logical”);
tExpr.setAttribute(“op”, “and”);
for(var h=0; h<tTable.length; ++h)
{
var tPromptCells_New = tTable[h].getElementsByTagName(“TD”);
for(var i=0; i<tPromptCells_New.length; ++i)
{
var tElement = tPromptCells_New[i];
if(tElement.getAttribute(“GFPBuilder”) != null)
{
try
{
var tFilter = eval(tElement.getAttribute(“GFPBuilder”));
if(tFilter)
{
tExpr.appendChild(tFilter);
}
}
catch(e)
{
alert(‘xxxx ‘+e);
return;
}
}
}
}
var tDelayedDash = document.getElementById(“sawDashboardDelayed”);
if(tExpr.childNodes.length==0 && !document.getElementById(“sawDashboardDelayed”))
return false;
else if(tExpr.childNodes.length==0)
tExpr = null;
else if(tExpr.childNodes.length==1)
tExpr=tExpr.childNodes[0];
if(tExpr)
{
tExpr.setAttribute(“xmlns:xsi”, “http://www.w3.org/2001/XMLSchema-instance”);
}
// inline report load support on dashboard
// now we have a switch to control whether we do it inline
var tForm = GetViewForm(”, -1, bGFPReloadInline);
if(sViewID==ksGFPStatePath)
{
var tRoot = XUIGetRootXML(“idXUIGFPPreview”);
tForm.P1.value = saw.getXmlText(saw.getFirstChildElement(tRoot));
tForm.action = saw.commandToURL(“ViewPreview”);
submitViewForm(tForm, null);
return;
}
GFPApplyFilters(tForm, tExpr, sViewID);
return false;
}

Here is the dashboard page I am going to modify:
dash1


The second step is to go to your dashboard page and add a “Text” dashboard object.
dash2

Edit the Text object by going to the properties button and pasting the code below and checking the “Contains HTML Markup” check-box.
<script> function foo(){
try{
var aElm = document.getElementsByTagName(‘table’);
var tTableArray = new Array();
var k = 0;
for(var i=0; i<aElm.length; i++){
if(aElm[i].className==’GFPBox’){
tTableArray[k] = document.getElementById(aElm[i].id);
k++;
}
}
GFPDoFilters_samvi(”, tTableArray, true);
}
catch(e)
{alert(‘XXX ‘ + e);}
}</script>
<div class=”XUIPromptEntry minibuttonOn” align=”right”><a href=”#” onclick=”javascript:foo();”>Go</a></div>

dash3
Save and that’s it.  You will need to restart presentation services in order for the function added in the js file to take so I would do that first before testing the new button or you will get function not found or some error like that.
dash4

Happy Coding and let me know if you have any ?s.

Prompt Reset Button


The code below creates a button in OBIEE that resets the prompt to its default values. Just add a text object to your dashboard and insert this code.
<div><a href=”#” onclick=”return PersonalizationEditor.removeDefaultSelection(false)”>Reset Prompts</a></div>
It will look like this: