ScheduleWithFormat.csp


<%@ Language=JavaScript%>

<%

// This page is called form ChooseReport.csp. It schedules a report using the desired file

// format.  Some formats require extra options: these are hard coded here.

%>

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

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

<html>

<body>

<%


// Report format constants.

var ceFormatTextPaginated = 6;

var ceFormatTextTabSeparated = 7;

var ceFormatTextCharacterSeparated = 8;

var ceFormatExcel=1;


function ScheduleWithFormat(IStore, ReportID, Format)

{

    var Reports = IStore.Query("SELECT SI_ID, SI_NAME FROM CI_INFOOBJECTS WHERE SI_ID="+ReportID);

    if (Reports.Count == 0)

    {    

        return;

    }

    var Report=Reports.Item(1);

    

    var ScheduleInfo ;

    //Create an interface to the scheduling options for the report.

    ScheduleInfo = Report.SchedulingInfo;

    // Run the report once.

    ScheduleInfo.Type = 0;

    // Run it right now.

    ScheduleInfo.RightNow = true;

    

    // Get the actual Report object.

    var PluginInterface = Report.PluginInterface("");

    

    //Set the format.

    PluginInterface.ReportFormatOptions.Format = Format;

    

    // Depending on the format, extra options may be required. These are hard coded here.

    switch(Format)

    {

        case ceFormatTextPaginated:

            PluginInterface.ReportFormatOptions.TextFormatPaginated.LinesPerPage=60;

        break;

        case ceFormatTextTabSeparated:

            PluginInterface.ReportFormatOptions.TextFormatTabSeparated.IsSameDate=true;

            PluginInterface.ReportFormatOptions.TextFormatTabSeparated.IsSameNumber=true;

        break;

        case ceFormatTextCharacterSeparated:

            PluginInterface.ReportFormatOptions.TextFormatCharacterSeparated.IsSameDate = true;

            PluginInterface.ReportFormatOptions.TextFormatCharacterSeparated.IsSameNumber=true;

            PluginInterface.ReportFormatOptions.TextFormatCharacterSeparated.Quote="'";

            PluginInterface.ReportFormatOptions.TextFormatCharacterSeparated.Separator="$$";

        break;

        case ceFormatExcel:

            PluginInterface.ReportFormatOptions.ExcelFormat.BaseAreaType=4; //Details section.

            PluginInterface.ReportFormatOptions.ExcelFormat.HasColumnHeadings=true;

            PluginInterface.ReportFormatOptions.ExcelFormat.IsTabularFormat=true;

            PluginInterface.ReportFormatOptions.ExcelFormat.UseConstColWidth=false;

            PluginInterface.ReportFormatOptions.ExcelFormat.UseWorksheetFunc=true;

        break;

    }

    //Tell the APS to schedule the report.

    IStore.Schedule (Reports);

}



function Main()

// Retrieve the report ID and format that were posted and schedule the report.

{

    IStore = RetrieveIStore();

    if (IStore == null)

    {

        Response.Redirect ("Start.csp");

        return;

    }

    ReportID = Request.Form.Item("ReportID");

    Format = Request.Form.Item("Format");

    ScheduleWithFormat(IStore,ReportID,Format);

    Response.Write ("Scheduled");

    

}


Main();

%>

</body>

</html>





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