Skip to Content
0
Former Member
Mar 06, 2009 at 03:03 PM

How to set the format and the destination for the scheduled report?

64 Views

Hi,

I studied the SDK and am trying to schedule a deski report through VBScript.

I managed to schedule it, but I can't get the ReportFormatOptions set to XLS and to change the outputfolder+file when I try to schedule the report by SI_ID. I commented the parts where I can't get it to work. Does anyone has an idea how to do this for VBA/VBScript? The documentation in the SDK is not helping me too much.. Thanks

'===============================================================================
'Schedule Deski directly in XI
'===============================================================================
Sub ScheduleDeskI(myInfoStore, reportID,strFormat,strDestination,strLogfile,Prompts1, PromptValue1, Prompts2, PromptValue2, Prompts3, PromptValue3, Prompts4, PromptValue4, Prompts5, PromptValue5, Prompts6, PromptValue6, Prompts7, PromptValue7)
	'On Error Resume Next
    Dim query	
    Dim myInfoObjects
    Dim myInfoObject
    Dim mySchedulingInfo
    Dim myDeskIDoc
    Dim paramName
    Dim param
    Dim promptValues
    Dim i, j, k
    Dim Prompts(7)
    Dim PromptValue(7)
    Dim Values
    Dim myReportFormatOptions
	Dim myDiskUnmanagedOptions
	Dim myDestinationOptions
	Dim myDiskUnmanaged
	Dim myDestinationPlugin
    
    Prompts(1)=Prompts1
    Prompts(2)=Prompts2
    Prompts(3)=Prompts3
    Prompts(4)=Prompts4
    Prompts(5)=Prompts5
    Prompts(6)=Prompts6
    Prompts(7)=Prompts7

    PromptValue(1)=PromptValue1
    PromptValue(2)=PromptValue2
    PromptValue(3)=PromptValue3
    PromptValue(4)=PromptValue4
    PromptValue(5)=PromptValue5
    PromptValue(6)=PromptValue6
    PromptValue(7)=PromptValue7

	'Query for and retrieve the specified report object
	'===============================================================================
    query = "Select SI_ID,SI_KEYWORD, SI_OWNERID, SI_SCHEDULEINFO, SI_PROCESSINFO from CI_infoobjects WHERE SI_ID =" & reportID

    Set myInfoObjects  = myInfoStore.Query(query)
    Set myInfoObject = myInfoObjects(1)

	'Use the InfoObject.SchedulingInfo property to retrieve an instance of the SchedulingInfo object.    
	'===============================================================================
    Set mySchedulingInfo  = myInfoObject.SchedulingInfo
    Set myDeskiDoc = myInfoObject.PluginInterface("FullClient")

	'Set the scheduling options. 
	'===============================================================================
    If myDeskiDoc.HasPrompts = True Then

        For Each param In myDeskiDoc.FullClientPrompts
        	i = 0
            paramName = param.Name
			'WriteLineToFile strLogfile, FormatDate(Now(), "yyyymmdd_hhnnss") & ";Report " & reportID & " has default param " & param.Name & "=" & promptValues.Item(1)
            For j = 1 To 7
	            If paramName = Prompts(j) Then
	                Set promptValues = param.Values
	                promptValues.Clear()
	                values=split(PromptValue(j),";")
	                For k = 1 To UBound(values)
	                	If values(k)<>"" Then
	                		promptValues.Add(values(k))
	                	End If	
	            	next
	                i = 1
	            End If
        	Next
			If i = 0 Then
				WriteLineToFile strLogfile, FormatDate(Now(), "yyyymmdd_hhnnss") & ";Report " & reportID & " has different prompts than configured."
			End If
        Next
    End If

    mySchedulingInfo.RightNow = 1
    'mySchedulingInfo.Type = ceScheduleTypeOnce
    'mySchedulingInfo.BeginDate = DateValue("31-Mar-09 2:39:49 AM")
    'mySchedulingInfo.EndDate = DateValue("31-Mar-09 2:39:49 AM")
    mySchedulingInfo.RetriesAllowed = 3
    mySchedulingInfo.RetryInterval = 600

	'Obtain the report instance's format using the ReportFormatOptions property. 
	'===============================================================================
'	Set myReportFormatOptions = myInfoObject.ReportFormatOptions
'	Select Case UCase(strFormat)
'		Case "XLS"
'			myReportFormatOptions.Format = CeReportFormat.ceFormatExcel
'		Case "PDF"	
'			myReportFormatOptions.Format = CeReportFormat.ceFormatPDF
'		Case "TXT"
'			myReportFormatOptions.Format = CeReportFormat.ceFormatTextTabSeparated
'		Case Else
'			myReportFormatOptions.Format = CeReportFormat.ceFormatExcel
'	End Select

	'Set the destination for the scheduled report. 
	'===============================================================================
'	Set myDestinationPlugin  = myInfoObject.DestinationPlugin
'	'Set myDestinationPlugin = myInfoObject.PluginInterface("Destination")
'	Set myDiskUnmanaged = myDestinationPlugin.DiskUnmanaged
'	Set myDestinationOptions = myDiskUnmanaged.ScheduleOptions
'	Set myDiskUnmanagedOptions = myDestinationOptions.DiskUnmanagedOptions
'  	myDiskUnmanagedOptions.DestinationFiles.Add(strDestination)
'	mySchedulingInfo.Destination.SetFromPlugin myDiskUnmanaged
	
	'Schedule the report using the InfoStore object. 
	'===============================================================================
    myInfoStore.Schedule myInfoObjects


    If (Err.Number = 0) Then
        WriteLineToFile strLogfile , FormatDate(Now(), "yyyymmdd_hhnnss") '& ";Report: " & reportID & " successfully scheduled."
    Else
        WriteLineToFile strLogfile , FormatDate(Now(), "yyyymmdd_hhnnss") & ";Error in ScheduleDeskI: " & reportID & " Error: " & Err.Description
    End If
End Sub