Setting scheduling options for FTP

Now that you have the InfoObject for the FTP destination, you can use the PluginInterface to set the scheduling options that are specific to FTP. These include:

For example:

FTPSchedulingOptions = FTP.PluginInterface("").ScheduleOptions;

FTPSchedulingOptions.Account = "jmudge";

FTPSchedulingOptions.ServerName = "ftp.pelican.com";

FTPSchedulingOptions.UserName = "jmudge";

FTPSchedulingOptions.Password = "password";

FTPSchedulingOptions.DestinationFiles.Add ("MyInstance.rpt");

FTPSchedulingOptions.Port = 21;

Once the FTP options are set, you must copy them into the Report.ScheduleInfo.Destination. This will cause the instance to be transferred via FTP after it has been processed. For example:

Report.SchedulingInfo.Destination.SetFromPlugin (FTP);

You are now ready to schedule the report using the InfoStore. The complete example for scheduling via FTP is given below. You can now choose to go to:

Example

function ScheduleToFTP(IStore,ReportId, ServerName, AccountName, UserName, Password, FilePath, Port)

{

    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;

    

    var FTPSchedulingOptions;

    var FTP;

    FTP = IStore.Query("Select Top 1* from CI_SYSTEMOBJECTS where SI_PARENTID=29 and SI_NAME='crystalenterprise.ftp'").Item(1);

    FTPSchedulingOptions = FTP.PluginInterface("").ScheduleOptions;

    FTPSchedulingOptions.Account = AccountName;

    FTPSchedulingOptions.ServerName = ServerName;

    FTPSchedulingOptions.UserName = UserName;

    FTPSchedulingOptions.Password = Password;

    FTPSchedulingOptions.DestinationFiles.Add (FilePath);

    FTPSchedulingOptions.Port = Port;

    

    ScheduleInfo.Destination.SetFromPlugin (FTP);

    

    //Tell the APS to schedule the report.

    IStore.Schedule (Reports);

}



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