Skip to Content
author's profile photo Former Member
Former Member

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

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.