Showing posts with label button. Show all posts
Showing posts with label button. Show all posts

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:
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{
var tPromptCells_New = tTable[h].getElementsByTagName(“TD”);
for(var i=0; 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.

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.
It will look like this:

Hide the Go button in OBIEE




If you need to hide the go button for a dashboard prompt in OBIEE insert a static text object on to the dashboard, select the “Contains HTML Markup” option and enter the following text into it:

OBIEE Column header hover text




By default OBIEE does not allow HTML or JavaScript coding in the headers, which is necessary to do this. To enable it, insert the following element to the instanceconfig.xml file. I placed it right after the tag.
false
This is the format of the code to place in the column header so that the text will hover.
The result would look something like this.

Popular Posts