Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get the report description? 1

Status
Not open for further replies.

ericb1

Programmer
Oct 22, 2004
175
US
Hopefully this is rather simple. Using CE10, I can use a link like the one below to grab the thumbnail of a report:

<img src="
But how can I do something similiar to get the description of the report, or for that matter, the other information of the report, such as the title, created on date, last modified date, etc. I assume it's something similiar to the "cmd=thumbnail", but just don't know.

Any help is greatly appreciated, thanks!
 
You can see that on crystal console management.Go to CMC and select the report and click that you can see created, last modified, last run. You can write description of the report in CMC but if you change the report and save that you are going to loose that. So you can add report description in Crystal Report. Click on file menu and click on summary info and type a description in comments and save the report, it will work fine.
 
Hi,
Actually you can change this behavior( You can write description of the report in CMC but if you change the report and save that you are going to loose that.) ..

If you click on Refresh Options on the Properties tab for a repprt you can uncheck the Description option and it will not be changed if the report is changed and resaved( directly from the CR Designer, of course)..
( other refresh options can also be selected/deselected).



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks guys, but I was actually trying to create my own ASP web page that called this information: my own asp code of an intranet here I'm designing, where the user can click on a report name, and see the thumbnail img, get the report desc, etc.

So far, it's proving much more difficult than I imagined. But my original post was about the "infoobject.cwr". I found that you could put the cmd=thumbnail on it and call the thumbnail, so I was hoping there was a method to do the same thing and just say cmd=description or something like that and get the description...

Thanks!
 
Hi,

The description is one of the attributes you can get from a
InfoObject query:
Here is a function ( in JavaScript, but can be adapted to VbScript) that will create an HTML table with the description as a clickable line( we use it to provide a user interface for selection of a report to run)..Its basic code can be adapted to to what you want it to..Especially look at the Query ( neds to have an Istore set up first, of course).

Code:
function RetrieveReports(ParentID ,IStore) 
{
//This returns an HTML table that is populated with the report name,
//report description, and the last time it was modified.

//Precondition:
//ParentID - The ID of the parent folder containing the reports to be retrieved.
//IStore - The InfoStore object required to interface with server.


//Postcondition:
//Returns an empty string if there are no reports, null if an error occurred, and
//the string if successful.

//Notes:
//The function returns a string that is an HTML table. 
	//The query that will select the reports.
	var Query;  
	//The result of the query.
	var Result;
	//A string to hold the HTML table.
	var HTMLTable; 
	HTMLTable="";

	//Create a query that selects all the reports, but doesn't select the instances.
	Query = "Select SI_NAME, SI_ID, SI_DESCRIPTION, SI_UPDATE_TS From CI_INFOOBJECTS Where " +
	"SI_PROGID='CrystalEnterprise.Report' And SI_INSTANCE=0 AND SI_PARENT_FOLDER=" + ParentID +
	"ORDER BY SI_DESCRIPTION";
		
		
	//Query the server.
	try {
		Result = IStore.Query(Query) ;
	}
	catch(e) {
		return null;
	}
	 
   
	if (Result.Count > 0) {
		//Set up the table header.
		HTMLTable="<TABLE width = \"800\" >" +
		"<TR><TH align='left'><B></B></TH>" +
		"<TH align='left'><B></B></TH></TR>"; 
				
		for (k=1;k<=Result.Count;k++)
		//Add the report name and details to the table.	
		{ 
		         if (Result.Item(k).Description == "") {
			var desc1 = Result.Item(k).Title;
			}
			else {
			var desc1 = Result.Item(k).Description;
			}
						//If No description, use the Title

			HTMLTable=HTMLTable +
				"<TR  valign=top><TD>" + 
				"<A   class='tableLink' title='Report Name: " + Result.Item(k).Title + "' HRef='#' onClick=\"navReport('" + Result.Item(k).ID +"')\">" +
				Server.HTMLEncode(desc1) + "</A></TD>" ;
		} 
		HTMLTable=HTMLTable+"</TABLE>";
	}
	    
	return( HTMLTable);
}



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks TB. Can you give me any help on setting up the IStore?

From a BO document I got off their site, it says to do it like this:

<%
'DECARE VARIABLES
Dim username
Dim password
Dim apsname
Dim authentication
Dim sm
Dim es
Dim iStore

username = "Administrator"
password = "xxxx"
apsname = "xxxx"
authentication = "secEnterprise"

'CREATE A SESSION MANAGER SO THAT WE CAN LOGON
Set sm = CreateObject("CrystalEnterprise.SessionMgr")

'LOGON USER
Set es = sm.Logon(username, password, apsname, authentication)

'STORE THE INFOSTORE SESSION
Set iStore = es.Service ("", "InfoStore")
%>


I don't get any errors, so I assume it's logging on (I get an error if I put in a bad password). But I have your javascript right after this function, but nothing is displayed.

Thanks again!
 
HI,
Try this function call ( instead of the ones you use after the setting of the variables for ID)

Code:
function LogonUser(username, password, apsname, authentication) {
	var sm;
	var es;
	var ltm;
	//INSTANTIATE INFOSTORE OBJECT FOR SESSION
    try {
		sm = Server.CreateObject("CrystalEnterprise.SessionMgr");
    	es = sm.Logon(username, password, apsname, authentication);
	} catch (e) {
		//LOGON ERROR
		SetCookies_LogonInfo(usr, aps, aut);
		SetSession("ErrMessage", e.description);
		Response.Redirect("yourlogonpage.asp?action=logonerror");
		Response.End();
    }
	SetSession("IStore", es.Service ("", "InfoStore"));
	SetSession("userID", username);
	SetSession("aps", es.APSName + es.ClusterName);
	try {
		ltm = es.LogonTokenMgr;
	} catch (e) {
		WriteErrorGeneral(e.description);
	}
	//WRITE THE LOGONTOKEN TO A COOKIE AND THE VIEW TOKEN TO A COOKIE
	try {
		SetCookie("logontoken", ltm.CreateLogonTokenEx("", 480, -1));
	} catch (e) {
		WriteErrorGeneral(e.description);
	}

	//CHECK IF PASSWORD HAS EXPIRED
	if (authentication == "secEnterprise") {	
		if(es.UserInfo.PasswordExpiry == 0) {
			SetCookies_LogonInfo(username, password, authentication);
			SetSession("ErrMessage", L_PASSWORDEXPIRED);
			Response.Redirect("newpwdform.csp");
			Response.End();
		}
	}
	}

Then try this one to actually set up the IStore object:

Code:
function RetrieveIStore() 
{ 
//Precondition: None

//Postcondition:
//Returns the InfoStore object that allows you to query the server.

//The function returns null if it does not succeed. 

	var LogonToken;
	var SessionManager;
	var Sess;
	
	// Check to see if the cookie is there
		if (GetCookie("LogonToken") == "" ) {
	  		
		    	 Response.Write ("<BR>Problem logging in to Crystal Server");
		    	 return(null);
	  		}
		

	//Try to retrieve the cookie.
	LogonToken = GetCookie("LogonToken");
	
	//Check to see if a logon token was really retrieved.
	if( LogonToken != "" ) 
	{
			
		//Check to see if the InfoStore already exists.
		if( typeof(Session.Value("IStore").Item) != "object" ) 
		{
			//Create a session manager.
			SessionManager = Server.CreateObject("CrystalEnterprise.SessionMgr");
						
			//Logon using the token. This may fail if the token is no longer valid.
			Sess = SessionManager.LogonWithToken(LogonToken);
						
			//Create the InfoStore object.
			IStore = Sess.Service("", "InfoStore");

			//Save the InfoStore in the session.
			SetSession("IStore",IStore);
			return (IStore);
		}
		else 
		{
			Response.Write ("RetrieveIStore 2");

			//The InfoStore already exists so simply retrieve it from
			//the session.
			IStore = GetSession("IStore")
			return(IStore);
		}
	}
											
	
	else{
      return(null); 
	}
    }


Once these 2 have run then call the Function that does the query....( the one I posted but with your specifics)

There are several ways to code this, but these work for me..

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Sorry, I'm a little slow. Thanks for your help. I assume these are all javascript functions? I've removed everything from my page except these scripts, but all I get is a blank page. No errors, but no list of reports. Not sure where I'm going wrong.

I'll paste the entire thing at the end of this email, but I didn't know if I need to alter the query or alter anything else to get it to work for me, besides the user name and password. Thanks again for your help.

Code:
<%
'DECARE VARIABLES
Dim username
Dim password
Dim apsname
Dim authentication
Dim sm
Dim es
Dim iStore

username = "Administrator"
password = "crystal10"
apsname = "DC01"
authentication = "secEnterprise"

'CREATE A SESSION MANAGER SO THAT WE CAN LOGON
Set sm = CreateObject("CrystalEnterprise.SessionMgr")

'LOGON USER
Set es = sm.Logon(username, password, apsname, authentication)

'STORE THE INFOSTORE SESSION
Set iStore = es.Service ("", "InfoStore")
%>

<script language="JavaScript" type="text/JavaScript">
function LogonUser(username, password, apsname, authentication) {
    var sm;
    var es;
    var ltm;
    //INSTANTIATE INFOSTORE OBJECT FOR SESSION
    try {
        sm = Server.CreateObject("CrystalEnterprise.SessionMgr");
        es = sm.Logon(username, password, apsname, authentication);
    } catch (e) {
        //LOGON ERROR
        SetCookies_LogonInfo(usr, aps, aut);
        SetSession("ErrMessage", e.description);
        Response.Redirect("yourlogonpage.asp?action=logonerror");
        Response.End();
    }
    SetSession("IStore", es.Service ("", "InfoStore"));
    SetSession("userID", username);
    SetSession("aps", es.APSName + es.ClusterName);
    try {
        ltm = es.LogonTokenMgr;
    } catch (e) {
        WriteErrorGeneral(e.description);
    }
    //WRITE THE LOGONTOKEN TO A COOKIE AND THE VIEW TOKEN TO A COOKIE
    try {
        SetCookie("logontoken", ltm.CreateLogonTokenEx("", 480, -1));
    } catch (e) {
        WriteErrorGeneral(e.description);
    }

    //CHECK IF PASSWORD HAS EXPIRED
    if (authentication == "secEnterprise") {    
        if(es.UserInfo.PasswordExpiry == 0) {
            SetCookies_LogonInfo(username, password, authentication);
            SetSession("ErrMessage", L_PASSWORDEXPIRED);
            Response.Redirect("newpwdform.csp");
            Response.End();
        }
    }
    }
</script>

<script language="JavaScript" type="text/JavaScript">
function RetrieveIStore() 
{ 
//Precondition: None

//Postcondition:
//Returns the InfoStore object that allows you to query the server.

//The function returns null if it does not succeed. 

    var LogonToken;
    var SessionManager;
    var Sess;
    
    // Check to see if the cookie is there
        if (GetCookie("LogonToken") == "" ) {
              
                 Response.Write ("<BR>Problem logging in to Crystal Server");
                 return(null);
              }
        

    //Try to retrieve the cookie.
    LogonToken = GetCookie("LogonToken");
    
    //Check to see if a logon token was really retrieved.
    if( LogonToken != "" ) 
    {
            
        //Check to see if the InfoStore already exists.
        if( typeof(Session.Value("IStore").Item) != "object" ) 
        {
            //Create a session manager.
            SessionManager = Server.CreateObject("CrystalEnterprise.SessionMgr");
                        
            //Logon using the token. This may fail if the token is no longer valid.
            Sess = SessionManager.LogonWithToken(LogonToken);
                        
            //Create the InfoStore object.
            IStore = Sess.Service("", "InfoStore");

            //Save the InfoStore in the session.
            SetSession("IStore",IStore);
            return (IStore);
        }
        else 
        {
            Response.Write ("RetrieveIStore 2");

            //The InfoStore already exists so simply retrieve it from
            //the session.
            IStore = GetSession("IStore")
            return(IStore);
        }
    }
                                            
    
    else{
      return(null); 
    }
    }
</script>



 
<script language="JavaScript" type="text/JavaScript">
function RetrieveReports(ParentID ,IStore) 
{
//This returns an HTML table that is populated with the report name,
//report description, and the last time it was modified.

//Precondition:
//ParentID - The ID of the parent folder containing the reports to be retrieved.
//IStore - The InfoStore object required to interface with server.


//Postcondition:
//Returns an empty string if there are no reports, null if an error occurred, and
//the string if successful.

//Notes:
//The function returns a string that is an HTML table. 
    //The query that will select the reports.
    var Query;  
    //The result of the query.
    var Result;
    //A string to hold the HTML table.
    var HTMLTable; 
    HTMLTable="";

    //Create a query that selects all the reports, but doesn't select the instances.
    Query = "Select SI_NAME, SI_ID, SI_DESCRIPTION, SI_UPDATE_TS From CI_INFOOBJECTS Where " +
    "SI_PROGID='CrystalEnterprise.Report' And SI_INSTANCE=0 AND SI_PARENT_FOLDER=" + ParentID +
    "ORDER BY SI_DESCRIPTION";
        
        
    //Query the server.
    try {
        Result = IStore.Query(Query) ;
    }
    catch(e) {
        return null;
    }
     
   
    if (Result.Count > 0) {
        //Set up the table header.
        HTMLTable="<TABLE width = \"800\" >" +
        "<TR><TH align='left'><B></B></TH>" +
        "<TH align='left'><B></B></TH></TR>"; 
                
        for (k=1;k<=Result.Count;k++)
        //Add the report name and details to the table.    
        { 
                 if (Result.Item(k).Description == "") {
            var desc1 = Result.Item(k).Title;
            }
            else {
            var desc1 = Result.Item(k).Description;
            }
                        //If No description, use the Title

            HTMLTable=HTMLTable +
                "<TR  valign=top><TD>" + 
                "<A   class='tableLink' title='Report Name: " + Result.Item(k).Title + "' HRef='#' onClick=\"navReport('" + Result.Item(k).ID +"')\">" +
                Server.HTMLEncode(desc1) + "</A></TD>" ;
        } 
        HTMLTable=HTMLTable+"</TABLE>";
    }
        
    return( HTMLTable);
}
</script>
 
Hi,
This set of functions ( yes, they are javascript) only create the HTML table, they do not disply it..
I sent the code mainly as an example of how to create the query that returns data from the CE system..

to actually see the table try this :

Code:
if (HTMLTable!=null ) 
	{
		Response.Write ("<span ><br /><br />Reports</span><BR><BR>");
		if (HTMLTable != "" ) 
		{
			Response.Write (HTMLTable);
		} else
			Response.Write ("No reports...");
	}
	else
	Response.Write ("There was an error trying to retrieve the reports.");
}


Or something similar..

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks TB. Javascript may as well be Chinese to me. Where would I put this? I put it in the RetreiveReports() function, but it doesn't seem to work. Does it need to be it's own script where I want the report to display?

Thanks so much
 
Hi,
Create an asp page that has this code on it and include the page with the functions,something like this( replacement of the last posting):
Main Page - Name it whatever you want - MyReports.asp, for instance:

Code:
<%@ Language=JavaScript%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- #include file="ce10_ReportHelper.asp"  -->
<html>
<head>


</head>

<body >

<%

var Result;
var ReportNames;
var ReportIDs;
var IStore;
var CurrentFolderID;
var Error;

//supply the  CurrentFolderID 

CurrentFolderID = <YOUR Folder ID HERE>;
LogonUser(username, password, apsname, authentication)
//Try to retrieve the InfoStore object.
IStore=RetrieveIStore();

if (IStore==null ) {
	//If it failed, redirect the user to the logon page.
	Response.Write ("There was an error with automatic login.");
	}
else
{        Query = "SELECT SI_DESCRIPTION FROM CI_INFOOBJECTS WHERE SI_PROGID = 'CrystalEnterprise.Folder' and SI_ID = " + CurrentFolderID;
	//Response.Write(Query);
	Result1 = IStore.Query(Query)
	var fname = Result1.Item.Description;
	//Response.Write(fname);
	var HTMLTable ;
	HTMLTable= RetrieveReports(CurrentFolderID,IStore);

	if (HTMLTable!=null ) 
	{
	  
		Response.Write ("<span class='tableHeadingGr'>" + fname + ": </span>");
		if (HTMLTable != "" ) 
		{
			Response.Write (HTMLTable);
		} else
			Response.Write ("No reports...");
	}
	else
	Response.Write ("There was an error trying to retrieve the reports.");
}
	 
%>
<br /><br /><br /><br />



</body>
</html>


Include Page ( Named CE10_Reporthelper:

Code:
<% 
function LogonUser(username, password, apsname, authentication) {
    var sm;
    var es;
    var ltm;
    //INSTANTIATE INFOSTORE OBJECT FOR SESSION
    try {
        sm = Server.CreateObject("CrystalEnterprise.SessionMgr");
        es = sm.Logon(username, password, apsname, authentication);
    } catch (e) {
        //LOGON ERROR
        SetCookies_LogonInfo(usr, aps, aut);
        SetSession("ErrMessage", e.description);
        Response.Redirect("yourlogonpage.asp?action=logonerror");
        Response.End();
    }
    SetSession("IStore", es.Service ("", "InfoStore"));
    SetSession("userID", username);
    SetSession("aps", es.APSName + es.ClusterName);
    try {
        ltm = es.LogonTokenMgr;
    } catch (e) {
        WriteErrorGeneral(e.description);
    }
    //WRITE THE LOGONTOKEN TO A COOKIE AND THE VIEW TOKEN TO A COOKIE
    try {
        SetCookie("logontoken", ltm.CreateLogonTokenEx("", 480, -1));
    } catch (e) {
        WriteErrorGeneral(e.description);
    }

    //CHECK IF PASSWORD HAS EXPIRED
    if (authentication == "secEnterprise") {    
        if(es.UserInfo.PasswordExpiry == 0) {
            SetCookies_LogonInfo(username, password, authentication);
            SetSession("ErrMessage", L_PASSWORDEXPIRED);
            Response.Redirect("newpwdform.csp");
            Response.End();
        }
    }
  }

function RetrieveIStore() 
{ 
//Precondition: None

//Postcondition:
//Returns the InfoStore object that allows you to query the server.

//The function returns null if it does not succeed. 

	var LogonToken;
	var SessionManager;
	var Sess;
	
	// Check to see if the cookie is there
		if (GetCookie("LogonToken") == "" ) {
	  		
		    	 Response.Write ("<BR>Problem logging in to Crystal Server");
		    	 return(null);
	  		}
		

	//Try to retrieve the cookie.
	LogonToken = GetCookie("LogonToken");
	
	//Check to see if a logon token was really retrieved.
	if( LogonToken != "" ) 
	{
			
		//Check to see if the InfoStore already exists.
		
			//Create a session manager.
			SessionManager = Server.CreateObject("CrystalEnterprise.SessionMgr");
						
			//Logon using the token. This may fail if the token is no longer valid.
			Sess = SessionManager.LogonWithToken(LogonToken);
						
			//Create the InfoStore object.
			IStore = Sess.Service("", "InfoStore");

			//Save the InfoStore in the session.
			SetSession("IStore",IStore);
			return (IStore);
		}
		
	
											
	
	
    }
    	
function RetrieveReports(ParentID ,IStore) 
{
//This returns an HTML table that is populated with the report name,
//report description, and the last time it was modified.

//Precondition:
//ParentID - The ID of the parent folder containing the reports to be retrieved.
//IStore - The InfoStore object required to interface with server.


//Postcondition:
//Returns an empty string if there are no reports, null if an error occurred, and
//the string if successful.

//Notes:
//The function returns a string that is an HTML table. 
	//The query that will select the reports.
	var Query;  
	//The result of the query.
	var Result;
	//A string to hold the HTML table.
	var HTMLTable; 
	HTMLTable="";

	//Create a query that selects all the reports, but doesn't select the instances.
	Query = "Select SI_NAME, SI_ID, SI_DESCRIPTION, SI_UPDATE_TS From CI_INFOOBJECTS Where " +
	"SI_PROGID='CrystalEnterprise.Report' And SI_INSTANCE=0 AND SI_PARENT_FOLDER=" + ParentID +
	"ORDER BY SI_DESCRIPTION";
		
		
	//Query the server.
	try {
		Result = IStore.Query(Query) ;
	}
	catch(e) {
		return null;
	}
	 
   
	if (Result.Count > 0) {
		//Set up the table header.
		HTMLTable="<TABLE width = \"800\" >" +
		"<TR><TH align='left'><B></B></TH>" +
		"<TH align='left'><B></B></TH></TR>"; 
				
		for (k=1;k<=Result.Count;k++)
		//Add the report name and details to the table.	
		{ 
		         if (Result.Item(k).Description == "") {
			var desc1 = Result.Item(k).Title;
			}
			else {
			var desc1 = Result.Item(k).Description;
			}
			var desc = Result.Item(k).Description
			//var descSize = desc.length - 1;
			//var descDisplay = desc.substr(3,descSize);
			HTMLTable=HTMLTable +
				"<TR  valign=top><TD>" + 
				"<A   class='tableLink' title='Report Name: " + Result.Item(k).Title + "' HRef='#' onClick=\"navReport('" + Result.Item(k).ID +"')\">" +
				Server.HTMLEncode(desc1) + "</A></TD>" ;
		} 
		HTMLTable=HTMLTable+"</TABLE>";
	}
	    
	return( HTMLTable);
}

%>


These 2 should give you enough ideas to customize it like you want it to look.
NOTE: This version of the HTML table includes a call to a function (navReport(), not shown) than calls whatever report in the table is clicked on)


[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Wow, thanks so much! That's awesome. Let me know if I'm being a pest.

I'm just stuck on these 3 lines (in CE10_Reporthelper)

SetSession("IStore", es.Service ("", "InfoStore"));
SetSession("userID", username);
SetSession("aps", es.APSName + es.ClusterName);

It's giving me an "object expected" error, but I'm not sure what it's looking for. In the main page, at the top, I defined username, password, apsname, and authentication. And so this should be the same in the included page, I added it to reporthelper page too, but that didn't work.

Also, what's the "CurrentFolderID" defined for? I left that blank, not sure if I have to supply something or not.

Thanks again in advance.

 
Hi,
Not sure ( did it give a line # in the error text?)
To test,comment them out and uncomment 1 at a time to see which line is confused about its object..

As to Folder ID, that is specific to your setup..The folder in which you have published your reports has a unique ID#..To find it, in the CMC, right-click on the folder name and look at the properties..The last number is the ID..

Using a custom interface like this is not trivial, but you will learn much about CE's abilities by trying it..Just keep experimenting, it will eventually become clear..

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks again TB. Yeah, I commented out all 3, plus some other dependent lines, but each one of those 3 lines when uncommented by itself gives a "Microsoft JScript runtime (0x800A138F) Object expected" error

Thanks again, I'll keep at it!
 
Hi,
I'll do some testing with the code I posted and see what I can find out ( They are extracts from a larger set of files we use to handle this, so I may have missed something.)



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Hi,
My Bad [banghead]
Create a file ( name it helper_js.asp ) using this ( CE supplied, so you may have it somewhere)

Code:
<!--
	File Version Start - Do not remove this if you are modifying the file 
	Build: 8.5.2
	File Version End
-->

<%
// helper_js.asp
//
// This file contains a number of common helper functions.
//

//LOCALIZATION STRINGS *****************************************************************************************
var L_SUCCESS="Success";
var L_FAILED="Failed";
var L_RUNNING="Running";
var L_PENDING="Pending";
var L_RECURRING="Recurring";
var L_PAUSED="Paused";
var L_STOPPED="Stopped";
var L_UNKNOWN = "Unknown";
//END OF LOCALIZATION STRINGS **********************************************************************************
%>

<%

// Constants
var C_SI_CAN_CREATE_USERS = "SI_CAN_CREATE_USERS";
var C_SI_IS_VALID_PRODUCT = "SI_IS_VALID_PRODUCT";
var vbCRLF = "\n";
var GUEST_ID = 11;
var C_MAXLONGINT = 2147483647;

function IsCSP()
{
	var bCSP = false;
	var hostname = String(Request.ServerVariables.Item("WCS_HOST_NAME"));
	if (hostname.length > 0 && hostname != "undefined")
		bCSP = true;

	return bCSP;
}

function IsWin32Server()
{
	var bWin32 = false;
	var path = String(Request.ServerVariables.Item("PATH_TRANSLATED"));
	if (path.indexOf(":\\") > 0)
		bWin32 = true;
	return bWin32;
}

function GetSession(name)
{
	if (IsWin32Server())
		return Session.Value(name);
	else
		return Session.Value(name).Item;
}

function SetSession(name, value)
{
	if (IsWin32Server())
		Session.Value(name) = value;
	else
		Session.Value(name).Item = value;
}

function GetCookie(name)
{
	return String(Request.Cookies.Item(name));
}

function GetSubCookie(name, subkey)
{
	if (IsCSP())
		return Request.Cookies.Item(name).SubItem(subkey);
	else
		return Request.Cookies(name)(subkey);
}

function SetCookie(name, value)
{
	if (IsCSP())
		Response.Cookies.Item(name).Value = value;
	else
		Response.Cookies(name) = value;
}

function SetSubCookie(name, subkey, value)
{
	if (IsCSP())
		Response.Cookies.Item(name).SubItem(subkey, value);
	else
		Response.Cookies(name)(subkey) = value;
}

function SetCookiePath(name, path)
{
	Response.Cookies.Item(name).Path = path;
}

function SetCookieExpires(name, expDate)
{
	Response.Cookies.Item(name).Expires = expDate;
}

function GetQueryString(name)
{
	if (arguments.length > 0)
		return Request.QueryString.Item(name);
	else
		return Request.QueryString.Item();
}

function GetFormItem(name)
{
	if (arguments.length > 0)
		return Request.Form.Item(name);
	else
		return Request.Form.Item();
}

function GetServerVariable(name)
{
	return Request.ServerVariables.Item(name);
}

if(IsWin32Server())
	Date.fromVarDate = function(v) { return new Date(v); }




function twoDigitString (n)
{
  var s = String (n);
  if (s.length == 1)
    return "0" + s;
  else
    return s;
}


// HERE'S OUR OWN VERSIONS OF LOCALISED DATE TIME STRINGS
// ALL MAPPED TO Date.toCELocaleString()

function DisplayDateTimeDE (d)    // Format: dd.MM.yyyy HH:mm:ss
{
  var gen_delim   = " ";
  var date_delim  = ".";
  var time_delim  = ":";
  var year        = d.getFullYear();
  var month       = twoDigitString (d.getMonth()+1);
  var day         = twoDigitString (d.getDate());
  var hours       = twoDigitString (d.getHours());
  var minutes     = twoDigitString (d.getMinutes());
  var seconds     = twoDigitString (d.getSeconds());

  var ret = day + date_delim + month + date_delim + year + gen_delim
          + hours + time_delim + minutes + time_delim + seconds;
  return ret;
}

function DisplayDateTimeEN (d)  // Format: M/d/yyyy h:mm:ss AMorPM
{
  var gen_delim    = " ";
  var date_delim  = "/";
  var time_delim  = ":";
  var year        = d.getFullYear();
  var month       = d.getMonth()+1;
  var day         = d.getDate();
  var AMPM        = "AM"
  var hours       = d.getHours();
  if (hours >= 12)
    AMPM = "PM";
    
  if (hours == 0)
	hours = 12;   
    
  if (hours != 12)  
	hours         = hours % 12;
  var minutes     = twoDigitString (d.getMinutes());
  var seconds     = twoDigitString (d.getSeconds());

  var ret = month + date_delim + day + date_delim + year + gen_delim
          + hours + time_delim + minutes + time_delim + seconds + gen_delim + AMPM;
  return ret;
}

function DisplayDateTimeFR (d)    // Format: dd/MM/yyyy HH:mm:ss
{
  var gen_delim   = " ";
  var date_delim  = "/";
  var time_delim  = ":";
  var year        = d.getFullYear();
  var month       = twoDigitString (d.getMonth()+1);
  var day         = twoDigitString (d.getDate());
  var hours       = twoDigitString (d.getHours());
  var minutes     = twoDigitString (d.getMinutes());
  var seconds     = twoDigitString (d.getSeconds());

  var ret = day + date_delim + month + date_delim + year + gen_delim
          + hours + time_delim + minutes + time_delim + seconds;
  return ret;
}

function DisplayDateTimeJA (d)    // Format: yyyy/MM/dd H:mm:ss
{
  var gen_delim   = " ";
  var date_delim  = "/";
  var time_delim  = ":";
  var year        = d.getFullYear();
  var month       = twoDigitString (d.getMonth()+1);
  var day         = twoDigitString (d.getDate());
  var hours       = d.getHours();
  var minutes     = twoDigitString (d.getMinutes());
  var seconds     = twoDigitString (d.getSeconds());

  var ret = year + date_delim + month + date_delim + day + gen_delim
          + hours + time_delim + minutes + time_delim + seconds;
  return ret;
}

if (GetLang() == "de")
  Date.toCELocaleString = DisplayDateTimeDE;
else if (GetLang() == "fr")
  Date.toCELocaleString = DisplayDateTimeFR;
else if (GetLang() == "ja")
  Date.toCELocaleString = DisplayDateTimeJA;
else
  Date.toCELocaleString = DisplayDateTimeEN;  // default



// FUNCTION WHICH WILL CREATE AN ABSOLUTE PATH SO OUR LINKS WILL WORK IN CGI
function GetLinkPath()
{
	var ret = "";
	var path_info = String(Request.ServerVariables.Item("PATH_INFO"));
	var regex = /[^\/]*\//g;
	var matchArr = path_info.match(regex);
	for(var i = 0; i < matchArr.length; ++i)
	{
		ret += matchArr[i];
	}

	return ret;
}

function GetParentLinkPath()
{
	var ret = "";
	var path_info = String(Request.ServerVariables.Item("PATH_INFO"));
	var regex = /[^\/]*\//g;
	var matchArr = path_info.match(regex);

	for(var i = 0; i < (matchArr.length -1); ++i)
	{
		ret += matchArr[i];
	}

	return ret;
}

// JAVASCRIPT ENCODES A STRING (I.E., REPLACES CARRIAGE RETURNS, SINGLE QUOTES, DOUBLE 
// QUOTES, AND BACKSLASHES WITH THE ESCAPED EQUIVALENTS)
function JSEncode(str)
{
	str = String(str);
	var j = 0;
	var strLen;
	var ch;
	strLen = str.length-1;
	while(j <= strLen)
	{
		ch = str.charAt(j);
		if(ch == '\'' || ch == '"' || ch == '\\')
		{
			str = str.substring(0, j) + "\\" + ch + str.substring(j+1, strLen+1);
			++strLen;
			++j;
		}
		else if(ch == '\n' || ch == '\r')
		{
			str = str.substring(0, j) + " " + str.substring(j+1, strLen+1);
		}
		++j;
	} 
	return str;
}

function SetPageExpiry()
{
	var exp = new Date();
	exp.setFullYear(exp.getFullYear()-1);
	Response.ExpiresAbsolute = exp.getVarDate();
}

function GetLang()
{
	var lang = String(Request.ServerVariables.Item("HTTP_ACCEPT_LANGUAGE"));
	lang = lang.substr(0, 2).toLowerCase();
	return lang;
}

function Trim(s)
{
	var ret = TrimLeft(s);
	ret = TrimRight(ret);
	return ret;
}

function TrimLeft(s)
{
	return s.replace(/^\s+/, "");
}

function TrimRight(s)
{
	return s.replace(/\s+$/, "");
}

// CHECKS IF THE SYSTEM PROPERTIES ALLOW CREATING NEW USERS
function CanCreateUsersSystem(es)
{
	try
	{
		var cancreateuser_version = es.SystemInfoProperties.Item(C_SI_CAN_CREATE_USERS).Value;
		if(!cancreateuser_version)
		{
			var isValidProduct = es.SystemInfoProperties.Item(C_SI_IS_VALID_PRODUCT).Value;
			// IF NOT VALID PRODUCT THEN SHOW LINKS AS IF PRO VERSION
			if(!isValidProduct)
				cancreateuser_version = true;
		}
		return cancreateuser_version;
	}
	catch(e)
	{
		return false;
	}
}

// CHECK IF THE ADMIN SETTINGS ALLOW CREATING NEW USERS
function CanCreateUsersAdmin(iStore)
{
	var cancreateuser_admin;
	try
	{
		var ufCol = iStore.Query("SELECT SI_ID FROM CI_SYSTEMOBJECTS WHERE SI_ID = 19");
		var rights = ufCol.Item(1).SecurityInfo.AnyPrincipal(GUEST_ID).Rights;
		var right = rights.Item("#1");		// check for AddRight
		cancreateuser_admin = right.Granted;
	}
	catch (e)
	{
		cancreateuser_admin = false;
	}

	return cancreateuser_admin;
}

function GetParam(name)
{
	var ret = Request.QueryString.Item(name);
	if(ret.Count == 0)
		ret = Request.Form.Item(name);

	return ret;
}


// Bitwise (XOR) comparison of 2 hresults to determine equality.
//
// Javascript stores numbers as floating-point, but this coerces them back to 32-bit integers so we
// can more easily compare hresults (given that failed hresults have the high-order bit turned on).
//
function EqualsHResult (hr1, hr2)
{
  if ((hr1 ^ hr2) == 0)
    return true;
  else
    return false;
}

// CONVERSION FUNCTIONS

function CheckedStringFromBool (b)
{
  if (b == true || b == -1)
    return "CHECKED";
  else
    return "";
}

function UncheckedStringFromBool (b)
{
  if (b == true || b == -1)
    return "";
  else
    return "CHECKED";
}


function BoolFromCheckBox (cb)
{
  if (cb.Count == 0)
    return false;
  else
    return true;
}

function DaysFromSeconds (s)
{
  return parseInt (s / 86400);
}

function SecondsFromDays (d)
{
  return parseInt (d) * 86400;
}


function MinutesFromSeconds (s)
{
  return parseInt (s / 60);
}

function SecondsFromMinutes (m)
{
  return parseInt (m) * 60;
}

// status constants
var ceStatusPending = 9;
var ceStatusPaused  = 8;
var ceStatusRunning = 0;
var ceStatusSuccess = 1;
var ceStatusFailure = 3;

function GetStatusString(obj)
{
	var ret = L_UNKNOWN;

	var status = obj.SchedulingInfo.Status;
	if(status == ceStatusPending)
	{
		if(obj.Properties.Item("SI_RECURRING") != 0)
		{
			ret = L_RECURRING;
		}
		else
		{
			ret = L_PENDING;
		}
	}
	else if(status == ceStatusRunning)
	{
		ret = L_RUNNING;
	}
	else if(status == ceStatusPaused)
	{
		ret = L_PAUSED;
	}
	else if(status == ceStatusSuccess)
	{
		ret = L_SUCCESS;
	}
	else if(status == ceStatusFailure)
	{
		ret = L_FAILED;
	}

	return ret;
}

// Function to Make a string query friendly by enclosing
// % _ [ ] - ^
// with [].
//
// Also change ' to ''
// 
// Used mostly in the conditional LIKE clause
function WrapWildCardCharsFromString( inStr )
{
	var outStr = inStr;

	// do ' first
	outStr = outStr.replace( /'/g, "''" );

	// now for % _ [ ] - ^
	outStr = outStr.replace( /([\%\_\[\]\-\^])/g, "[$1]" );

	return outStr;
}

// Function to "quote" an object's property, to be used in a query
//
// ObjectProp: a string value to quote
//
// Return value: the quoted string value
//
function QuoteObjectProp(ObjectProp)
{
    var QuotedObjectProp = ObjectProp.replace(/'/g, "''");
    return "'" + QuotedObjectProp + "'";
}

// Function to retrieve all the objects for a query.
//
// iStore:       an InfoStore object
// SelectProps:  the properties to return for each object
// ObjectTable:  the database table to query (CI_INFOOBJECTS or CI_SYSTEMOBJECTS)
// WhereClause:  the query restrictions
// OrderBy:      the property to sort the return set on
//
function GetCompleteCollection(iStore, SelectProps, ObjectTable, WhereClause, OrderBy)
{
	var queryStr = "SELECT " + SelectProps + " FROM " + ObjectTable + " WHERE " + WhereClause + " ORDER BY " + OrderBy + ",SI_ID";
	var col = iStore.Query(queryStr);
	var count = col.Count;
	var resultCount = col.ResultCount;
	var returnColl = col;

	while(resultCount > count)
	{
		var lastObj = col.Item(count);
		col = GetNextCollection(iStore, SelectProps, ObjectTable, WhereClause, OrderBy, lastObj);
		count = col.Count;
		resultCount = col.ResultCount;

		for(var i = 1; i <= count; ++i)
		{
			returnColl.Copy(col.Item(i), 0);
		}
	}

	return returnColl;
}

// Function to retrieve the next batch of objects in a query.
//
// iStore:       an InfoStore object
// SelectProps:  the properties to return for each object
// ObjectTable:  the database table to query (CI_INFOOBJECTS or CI_SYSTEMOBJECTS)
// WhereClause:  the query restrictions
// OrderBy:      the property to sort the return set on
// LastObject:   the last object from the previous collection (can be null for the first query)
//
function GetNextCollection(iStore, SelectProps, ObjectTable, WhereClause, OrderBy, LastObject)
{
	var queryStr = "SELECT " + SelectProps + " FROM " + ObjectTable + " WHERE " + WhereClause;
	if(LastObject)
	{
		var quotedLastValue = QuoteObjectProp(String(LastObject.Properties.Item(OrderBy)));
		var lastID = LastObject.ID;

		queryStr += " AND (" + OrderBy + " > " + quotedLastValue;
		queryStr += " OR (" + OrderBy + " = " + quotedLastValue + " AND SI_ID > " + lastID;
		queryStr += "))";
	}
	queryStr += " ORDER BY " + OrderBy + ",SI_ID";
	var returnColl = iStore.Query(queryStr);

	return returnColl;
}

%>

At the top of your first page, right after the other include, add one referencing this new file..

Enjoy...



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
HA! That totally works! You're awesome! Thanks again.

 
Hi,
Glad to help ( I needed lots when I started doing this stuff..)

Download this:
ce10_com_docs_en.zip

from Business Objects and when extracted, look at CE_SDK.CHM..Contains all the info on what is accessable from CE's objects...



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Wow, after much trial and error, I finally got it all working, including the thumbnail image of each report.

Thanks to all for their help on this one, and if anyone is looking for this, a listing of reports in CE10, with their thumbnails and descriptions, etc., let me know and I'll post my code.

Thanks again!

-Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top