BusinessObjects Board

Change XI 3.1 DeskI FullClient Refresh on Open via SDK

Hello,
Yes, this is a DeskI client in 2019. Doing a mass migration from 3.1 to 4.2 for a client and there are hundreds of reports coming out of the woodwork. Of course some of these have refresh on open and some have invalid local providers we can’t use now. So one task is to turn off the refresh piece. Now yes, I could open each report in DeskI and goto Tools-> Options → Save and uncheck the Refresh on open, but there are quite a few. So I am trying the old 3.1 SDK to do this.

I can connect to the system, load the FullClient Reports and iterate through them. I have a helper class that does all the queries, etc…


final String qry = "Select top 100000 * from CI_INFOOBJECTS where SI_KIND = 'FullClient' AND SI_INSTANCE = 0";
    
IInfoObjects objs = qh.run(qry);
for (int i = 0; i < objs.size(); i++) {
  IFullClient rpt = (IFullClient) objs.get(i);

   if (rpt != null) {
     if (rpt.getRefreshOnOpen()) {
         rpt.setRefreshOnOpen(false);
         rpt.save();
      }
   }
}

Now this actually iterates through, checks a flag in the query, supposedly sets the flag and saves. I can see the date updated on the report in the CMC after the save. And if I query on a report by its name in the AdminTools, I see the SI_ISREFRESHONOPEN is set to false if it was true, so that updates. BUT if I open a report in DeskI that was changed, the report itself didn’t actually change and going to Tools-> Options → Save still shows the Refresh Document When Opening Flag checked. :hb:

Has anyone done this before in SDK?
Thanks,
Nathan


ntruhan (BOB member since 2015-07-14)

You are using the BI Platform SDK. This does enable access to objects in the CMS, but for document types (DeskI, WebI, CR, Universes, etc.) you only have access to the object metadata. So you can see (and change) things like parent folder, owner, etc., but you cannot see or change stuff that’s stored in the document itself – this would include the query definition, report structure, variables, options, and more. SOME of the document properties are copied into the CMS object upon save – this includes the Refresh On Open property that you found. But, since this is a copy of the property in the CMS, modifying it will not actually do anything.

In order to modify the ROO property in the DeskI documents, you will need to use the DeskI COM library. This might not be as hard as it sounds. The DeskI application includes a VBA editor. You will just need to write a script to open a document from the CMS, do a “Save As” without ROO, and re-publish.

(I don’t have DeskI installed here, but I’m pretty sure the ROO property is set during Save As. It might be a document property, but it’s in there somehwere).


joepeters :us: (BOB member since 2002-08-29)

So I cobbled something together in VBA that opens the report and can remove the flag. However, one issue I have is that the report will auto-refresh the first time it opens and if there are prompts it can get stuck waiting for prompts until you switch over and cancel out of them to continue.

I tried to use the OpenFromEnterprise function to do this and it does open the report and I can use the SaveToEnterprise to republish the report.

The only way I can see to do it is to to retrieve the file using a oInfoObject.Files.Item(1).CopyTo … Then opening the local copy using:
Application.Documents.Open(FileName, True, False, “”,"")

This provided a NoAutomaticRefresh flag which I set to true. So it will retrieve them all and open them; however, for each of them it doesn’t seem to pull in the correct value for Automatic Refresh, it is always False, so I never can set the value properly.

Is there a hidden or alternate way to pull this so I don’t get stuck on reports doing a OpenFromEnterprise?

Thanks,
Nathan


ntruhan (BOB member since 2015-07-14)

Just a guess, but what if you open it (with NoAutomaticRefresh set to true), then just Save?


joepeters :us: (BOB member since 2002-08-29)

Hi,
here is my code solving this issue.
It automates Deski from Excel (2007 or above). You may find instructions in the comments.


'Use this code in Excel2007 or above
'Prerequisite: BusinessObjects XI 3.1 properly installed on your PC
'You MUST add reference to "BusinessObjects 12.0 Object Library" prior to use the code below (Tools\References)
'You should paste this code into an Excel worksheet (or ThisWorkbook) code module (Excel2007 or above)
'If the Immediate window not seen in your VBIDE then: View\Immediate Window
'Change CMSSourceFolder, CMSDestinationFolder, RepName
'Save your workbook as a Macro-Enabled Workbook (i.e. ROOtest.xlsm)
'Run the SetROO subroutine
Option Explicit
Option Base 1
'This macro implements Deski Application &amp; Document level events as described in the following document:
'"Desktop Intelligence Developer Guide BusinessObjects XI 3.1" , Chapter: "Desktop Intelligence events"
Private WithEvents iDoc As busobj.Document      'Deski Doc with events
Private WithEvents boApp As busobj.Application  'Deski App with events
Dim bAuth As Boolean                            'Logon success
Private CMSSourceFolder As String, CMSDestinationFolder As String
Private RepName As String, RepFullName As String
Private CategoryList As String
Private bDebug As Boolean               'Show/suppress event messages
Private bboApp_DocumentBeforeRefresh As Boolean
Private DPIsRefreshable() As Boolean    'Stores dataproviders' IsRefreshable property
Private i As Long                       'For DPs cycle
 
Private Sub SetROO()
    On Error GoTo ErrorHandler
    Application.DisplayAlerts = False
    bDebug = True   'If you do not want to see the event messages change it to False
    Set boApp = New busobj.Application
    boApp.Visible = True    'We shall see what's going on in Deski
    boApp.Interactive = True   'For LogonDialog
    bAuth = boApp.LogonDialog
    CMSSourceFolder = "XARCH/ROO"   'Change your source folder path
    CMSDestinationFolder = "XARCH/ROO"  'Change your destination folder path (may be same as source folder)
    RepName = "D01Toroltek_3"   'Change your test report name here
    bboApp_DocumentBeforeRefresh = False
    Debug.Print Time, "Action: OpenFromEnterprise" &amp; " ,CMSSourceFolder - " &amp; CMSSourceFolder &amp; " ,RepName - " &amp; RepName
    Set iDoc = boApp.Documents.OpenFromEnterprise(RepName, CMSSourceFolder, BoEnterpriseFolderKind.BOFolder)
    boApp.Interactive = False   'Suppress alerts, questions,...
    RepFullName = iDoc.FullName
    CategoryList = iDoc.DocAgentOption.CategoryList &amp; "|AutoRefreshDisabled"
    Debug.Print Time, "Action: AutoRefreshWhenOpening set to False", iDoc.FullName
    iDoc.AutoRefreshWhenOpening = False 'ROO set False explicitly
    Debug.Print Time, "Action: iDoc.SaveToEnterprise - " &amp; CMSDestinationFolder &amp; "/" &amp; RepName, iDoc.AutoRefreshWhenOpening
    iDoc.SaveToEnterprise CMSDestinationFolder, BoEnterpriseFolderKind.BOFolder, CategoryList, "", True
    Debug.Print Time, "Action: iDoc.Close (boDontSave)", iDoc.FullName, iDoc.AutoRefreshWhenOpening
    iDoc.Close (boDontSave)
    Debug.Print Time, "Action: ReOpenFromEnterprise - " &amp; CMSDestinationFolder &amp; "/" &amp; RepName
    Set iDoc = boApp.Documents.OpenFromEnterprise(RepName, CMSDestinationFolder, BoEnterpriseFolderKind.BOFolder)
DocClose:
    Debug.Print Time, "Action: iDoc.Close (boDontSave)", iDoc.FullName, iDoc.AutoRefreshWhenOpening
    iDoc.Close (boDontSave)
CleanUp:
    On Error Resume Next
    Application.DisplayAlerts = True
    Set iDoc = Nothing
    If Not boApp Is Nothing Then boApp.Quit
    Set boApp = Nothing
Exit Sub
ErrorHandler:
    Debug.Print "ERROR! Err.Number: " &amp; Err.Number &amp; ",Err.Description: " &amp; Err.Description &amp; ". Going to clean up."
    Err.Clear
    Resume CleanUp
End Sub
 
'----------------------------------------------------
'Implementing Deski Document level events
Private Sub iDoc_Activate()
    If bDebug Then Debug.Print Time, "Event : iDoc_Activate", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
Private Sub iDoc_AfterRefresh()
    If bDebug Then Debug.Print Time, "Event : iDoc_AfterRefresh", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
Private Sub iDoc_BeforeClose(Cancel As Boolean)
    Debug.Print Time, "Event : iDoc_BeforeClose", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
Private Sub iDoc_BeforeRefresh(Cancel As Boolean)
    If bDebug Then Debug.Print Time, "Event : iDoc_BeforeRefresh", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
Private Sub iDoc_BeforeSave(Cancel As Boolean)
    If bDebug Then Debug.Print Time, "Event : iDoc_BeforeSave", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
Private Sub iDoc_Deactivate()
    If bDebug Then Debug.Print Time, "Event : iDoc_Deactivate", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
Private Sub iDoc_Open()
    If bDebug Then Debug.Print Time, "Event : iDoc_Open", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
 
'----------------------------------------------------
'Implementing Deski Application level events
Private Sub boApp_DocumentActivate(ByVal doc As busobj.IDocument)
    If bDebug Then Debug.Print Time, "Event : boApp_DocumentActivate - " &amp; doc.FullName, doc.AutoRefreshWhenOpening
End Sub
Private Sub boApp_DocumentAfterRefresh(ByVal doc As busobj.IDocument)
    If bDebug Then Debug.Print Time, "Event : boApp_DocumentAfterRefresh", doc.FullName, doc.AutoRefreshWhenOpening
End Sub
Private Sub boApp_DocumentBeforeClose(ByVal doc As busobj.IDocument, Cancel As Boolean)
    If bDebug Then Debug.Print Time, "Event : boApp_DocumentBeforeClose", doc.FullName, doc.AutoRefreshWhenOpening
End Sub
Private Sub boApp_DocumentBeforeRefresh(ByVal doc As busobj.IDocument, Cancel As Boolean)
'If ROO (AutoRefreshWhenOpening property) is True than this is the very first event
'1. All DataProviders IsRrefreshable property stored in DPIsRefreshable()
'2. All DataProviders IsRrefreshable property set to False so the DOCUMENT WILL NOT BE REFRESHED ANYWAY
    If bDebug Then Debug.Print Time, "Event : boApp_DocumentBeforeRefresh", doc.FullName, doc.AutoRefreshWhenOpening
    ReDim DPIsRefreshable(doc.DataProviders.Count)
    bboApp_DocumentBeforeRefresh = True
    For i = 1 To UBound(DPIsRefreshable)
        With doc.DataProviders(i)
        If bDebug Then Debug.Print Time, "Action: DataProvider " &amp; .Name &amp; " IsRefreshable property stored &amp; set to False."
        DPIsRefreshable(i) = .IsRefreshable
        .IsRefreshable = False
        End With
    Next i
End Sub
Private Sub boApp_DocumentBeforeSave(ByVal doc As busobj.IDocument, Cancel As Boolean)
'All DataProviders IsRrefreshable property restored from DPIsRefreshable()
    If bDebug Then Debug.Print Time, "Event : boApp_DocumentBeforeSave", doc.FullName, doc.AutoRefreshWhenOpening
    If bboApp_DocumentBeforeRefresh Then
        For i = 1 To UBound(DPIsRefreshable)
            With doc.DataProviders(i)
            If bDebug Then Debug.Print Time, "Action: DataProvider " &amp; .Name &amp; " IsRefreshable property restored - " &amp; DPIsRefreshable(i)
            .IsRefreshable = DPIsRefreshable(i)
            End With
        Next i
   End If
End Sub
Private Sub boApp_DocumentDeactivate(ByVal doc As busobj.IDocument)
    If bDebug Then Debug.Print Time, "Event : boApp_DocumentDeactivate", doc.FullName, doc.AutoRefreshWhenOpening
End Sub
Private Sub boApp_NewDocument(ByVal doc As busobj.IDocument)
    If bDebug Then Debug.Print Time, "boApp_NewDocument", doc.FullName, doc.AutoRefreshWhenOpening
End Sub
Private Sub boApp_DocumentOpen(ByVal doc As busobj.IDocument)
    If bDebug Then Debug.Print Time, "Event : boApp_DocumentOpen", doc.FullName, doc.AutoRefreshWhenOpening
End Sub

SuKA (BOB member since 2018-10-20)