ChooseReport.csp


<%@ Language=JavaScript%>

<%

// This example allows the user to schedule a report and have the instance delievered

// in a certain format. This page allows the user to a pick a report and a format. It then

// calls ScheduleWithFormat.csp to schedule the report.

%>

<!-- #include file="RetrieveIStore.csp" -->

<!-- #include file=helper_js.csp -->

<html>

<body>

<%


function GetFileFormats()


// Return a list box populated with all the formats that are supported by

// Crystal Enterprise.

{

    var Formats = new Array();

    Formats.push("Crystal Report");

    Formats.push("Microsoft Excel");

    Formats.push("Microsoft Word");

    Formats.push("Adobe PDF");

    Formats.push("Microsoft RTF");

    Formats.push("Plain Text");

    Formats.push("Paginated Text");

    Formats.push("Tab Seperated Text");

    Formats.push("Character Seperated Text");

    var HTML="<select name=Format>";

    for (k=0;k<Formats.length;k++)

    {

        HTML = HTML + "<option value='"+k+"'>"+Formats[k]

    }

    HTML= HTML + "</select>";

    return HTML;

}    


function GetReports(IStore)

{

    // This function returns a listbox popuplated with all reports.

    //

    // RETURNS

    // If there are no reports, an empty string is returned.

    var Reports = IStore.Query("SELECT SI_ID, SI_NAME FROM CI_INFOOBJECTS WHERE SI_PROGID='CrystalEnterprise.Report' And SI_INSTANCE=0");

    if (Reports.Count == 0)

    {    

        return "";

    }

    var k;

    var HTML="<select name=ReportID>";

    for (k=1;k<=Reports.Count;k++)

    {

        HTML = HTML + "<option value='"+Reports.Item(k).ID+"'>"+Reports.Item(k).Title;

    }

    HTML= HTML + "</select>";

    return HTML;

}




function Main()

// Print a form that allows the user to choose a report and a format.

{

    IStore = RetrieveIStore();

    if (IStore == null)

    {

        Response.Redirect ("Start.csp");

        return;

    }

    Response.Write ("<H2>Schedule a report using a specific file format</H2>");

    Response.Write ("<form action='ScheduleWithFormat.csp' method=post name='Schedule'>");

    Response.Write ("Report: <BR>");

    Response.Write (GetReports(IStore));

    Response.Write ("<BR><BR>Format: <BR>");

    Response.Write (GetFileFormats());

    Response.Write ("<BR><input type=submit name='Next' value='Schedule'>");

    Response.Write ("</FORM>");

}


Main();

%>

</body>

</html>




Crystal Decisions, Inc.
http://www.crystaldecisions.com
Support services:
http://support.crystaldecisions.com