Author: Steve Rademacher
Author notes: Use at your own risk. Caution this script deletes records from your repository. This is not recoverable and is not supported by SAP. This code works for me but it is up to you to review and test the code yourself. The purpose of this code is to purge old inbox records for inboxes that have 1000 or more reports in them. There is no built-in feature to purge inbox documents. In addition, every report sent to an inbox is another copy of the same report. These inbox reports take up a lot of space in the FRS.
This code only purges objects with a date older than 100 days. A log file is appended to called c:\inboxdeletelog.txt. The code does not delete the log file so it will grow forever.
Platform: Windows
Version: 1.0
Description: The code should be saved as a .vbs file. It can be run from the Windows scheduler, from the Program Object scheduler in Business Objects or manually. To test the code, remove or comment out the inboxRecords.Delete(inboxRecord) line. To run the code, call it as such: cscript inboxdelete.vbs {CMSname} administrator {adminpassword} secEnterprise.
The SI_CHILDREN>999 line limits the code to finding inboxes that have more than 999 records in them. The DateAdd(“d”, -100, Date) code (3 times) limits to finding inbox reports that have a last updated date more than 100 days ago. The TOP 100 code limits to delete maximum 100 documents. Run time on my largest repository with the current settings is 30 seconds. To delete more than 100 records, it is best to run this .vbs once for each 100 records. If you change any of these settings, be aware that sdk code may error out at 9 minutes and may use a lot of CPU time for your CMS while it is running.
' ************************************************************************
' Deletes old Inbox records for any user with more than 999 items in
' their inbox. Each time this is run, it will delete up to 100 documents.
' ************************************************************************
Dim APS
Dim UserID
Dim Password
Dim Aut
Dim oSessionManager
Dim oEnterpriseSession
Dim oSess
Dim OldSIName
OldSIName = " "
'For the logon, Authenticate as Following
APS = Wscript.Arguments(0)
UserID=Wscript.Arguments(1)
Password = Wscript.Arguments(2)
Aut = Wscript.Arguments(3)
'Create an Enterprise oSessionManager
Set oSessionManager = WScript.CreateObject("CrystalEnterprise.SessionMgr")
Set oSess = oSessionManager.Logon(UserID, Password, APS, Aut)
'Query the iStore and get up to 100 inbox items to delete
On Error Resume Next
'Create a new Variable for the login token
Set iStore = oSess.Service("", "InfoStore")
queryString = "select TOP 100 * from CI_INFOOBJECTS Where CHILDREN(""SI_NAME='Folder Hierarchy'"",""SI_KIND='Inbox' and SI_CHILDREN>999"") and SI_UPDATE_TS < '"
queryString = queryString & Year(DateAdd("d", -100, Date)) & "."
queryString = queryString & Right("00" & Month(DateAdd("d", -100, Date)), 2) & "."
queryString = queryString & Right("00" & Day(DateAdd("d", -100, Date)), 2)
queryString = queryString & "' order by SI_UPDATE_TS"
Set objFSO = CreateObject("scripting.filesystemobject")
Set logStream = objFSO.OpenTextFile("c:\inboxdeletelog.txt", 8, 1)
logStream.writeline "Server - DateTime: " & APS & " - " & FormatDateTime(Now,0)
logStream.writeline "Query: " & queryString
Set inboxRecords = iStore.Query(queryString)
for x = 1 to inboxRecords.Count
Set inboxRecord = inboxRecords.Item(x)
If inboxRecord.Properties.Item("SI_NAME").Value <> OldSIName Then
logStream.writeline "SI_OWNER-SI_KIND-SI_UPDATE_TS-SI_NAME-SIZE: " & inboxRecord.Properties.Item("SI_OWNER").Value & _
" - " & inboxRecord.Properties.Item("SI_KIND").Value & _
" - " & inboxRecord.Properties.Item("SI_UPDATE_TS").Value & _
" - " & inboxRecord.Properties.Item("SI_NAME").Value & _
" - " & inboxRecord.Properties.Item("SI_FILES").Properties.Item("SI_VALUE1").Value
inboxRecords.Delete(inboxRecord)
End If
OldSIName = inboxRecord.Properties.Item("SI_NAME").Value
Next
IStore.Commit(inboxRecords)
oSessionManager.logoff
logStream.Close
Steve Rademacher (BOB member since 2004-02-17)