Hi...
In my last post of " Uploading/calling PDF file into OBIEE 11g using Analysis " I had told that I will post if file/PDF does not exist on server then how to overcome for "Server Not Found" error,so here is the solution for that. I will directly start with Part 3 present in my last blog.
Calling PDF file dynamically in Analysis without getting Server Not Found issue.
If you want to call the PDF file dynamically then there should be one column which will hold the name of the PDF. You can create your separate table in DB which will hold the name of the PDF. Let say in presentation you have one dimension as PDF and it contains two column as PDF Number and PDF Name. suppose my PDF names are 41005.pdf,41006.pdf,41007.pdf and so on....no matter number or char as we can cast it.The steps are :
1. If data value is in number then cast it to char. to do this hover on column - Click on "Edit Formula" and cast the column from number to char data type.
2. Now to pass the value of the column to browser, hover you mouse pointer over column - select column properties - click on Data Format - enter the following :
@[html]"<a href=javascript:test1('http://myservername/analyticsRes/"@H".pdf')>"@"</a>"
Note : I have created small JavaScript and above I am passing parameter in test1 function whcih will hold the data value (PDF/File name) and if it is present then it will open up that particular (PDF/File name) and if it is not present then instead of showing Server Not Found message it will prompt user by showing custom message present in script for e.g "File Does Not Exists" or any user defined message.I will show it in upcoming steps.
3. Click on save. Save the analysis.
4. Now go on “Results” tab and select “Static Text” view and put following JavaScript :
In my last post of " Uploading/calling PDF file into OBIEE 11g using Analysis " I had told that I will post if file/PDF does not exist on server then how to overcome for "Server Not Found" error,so here is the solution for that. I will directly start with Part 3 present in my last blog.
Calling PDF file dynamically in Analysis without getting Server Not Found issue.
If you want to call the PDF file dynamically then there should be one column which will hold the name of the PDF. You can create your separate table in DB which will hold the name of the PDF. Let say in presentation you have one dimension as PDF and it contains two column as PDF Number and PDF Name. suppose my PDF names are 41005.pdf,41006.pdf,41007.pdf and so on....no matter number or char as we can cast it.The steps are :
1. If data value is in number then cast it to char. to do this hover on column - Click on "Edit Formula" and cast the column from number to char data type.
2. Now to pass the value of the column to browser, hover you mouse pointer over column - select column properties - click on Data Format - enter the following :
@[html]"<a href=javascript:test1('http://myservername/analyticsRes/"@H".pdf')>"@"</a>"
Note : I have created small JavaScript and above I am passing parameter in test1 function whcih will hold the data value (PDF/File name) and if it is present then it will open up that particular (PDF/File name) and if it is not present then instead of showing Server Not Found message it will prompt user by showing custom message present in script for e.g "File Does Not Exists" or any user defined message.I will show it in upcoming steps.
3. Click on save. Save the analysis.
4. Now go on “Results” tab and select “Static Text” view and put following JavaScript :
<script>
function
test1(strURL){
var test =
FileExists(strURL);
if(test == true)
window.location=strURL
else
alert("Sorry,
the pdf you have requested is not available.");
}
function
FileExists(strURL)
{
var req =
this.window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") :
new XMLHttpRequest();
req.open("GET",
strURL, false);
req.send(null);
if (req.status ==
200){
return 1;
}
return 0;
}
</script>
5. Please don't forget to click on "Contains HTML Markup" in “Static
Text” view. It will look like:
6. Here you may or may not include “Static
Text” view in Compound Layout. It just want script to be written and “Static
Text” view is the best option.Now save your analysis and check for results.
If file/PDF exists then it will open it and if it does not
exists then it will prompt user as below: