Advertisement

12.20.2007 at 07:00AM PST, ID: 23035882
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.2

Error: "Function Requires a Valid ADT Argument" Running a Script

Asked by niccilaw in Lotus Domino Email Server, Lotus Notes

Tags: , , , ,

I am getting this error when running an agent containing the code below.  I am not sure what is causing this or what is missing.  I am a novice to lotusscript.  I actually copied this code from an IBM Lotus Support tech note.

Sub Initialize
      Dim s As New NotesSession
      Dim w As New NotesUIWorkspace
      Dim destDb As New NotesDatabase("","")
      Dim sourceDb As New NotesDatabase("","")
      Dim AllDocs As NotesDocumentCollection
      Dim AllDocsView As NotesView
      Dim sourceDoc As NotesDocument
      Dim destDoc As NotesDocument
      Dim tempDoc As NotesDocument
      Dim docCount As Variant
      Dim current As Variant
      Dim choices (0 To 2) As Variant
      
      choices(0) = "Current Database"
      choices(1) = "Local Database"
      choices(2) = "Database on Server"
      
' get source database
      sourceDbType = w.Prompt(PROMPT_OKCANCELLIST, "Select Database Location",  _
      "Select the location of the database you would like to copy from:", _
      choices(0), choices)
      
      If sourceDbType = "" Then
            Messagebox "Operation cancelled"
            Exit Sub
      End If
      
      If sourceDbType = choices(0) Then
            Set sourceDb = s.CurrentDatabase
      Else
            If sourceDbType = choices(1) Then
                  sourceDbServer = ""
                  sourceDbNameReturn = w.OpenFileDialog(False, _
                  "Select the database you would like to copy from", "*.nsf", _
                  s.GetEnvironmentString("Directory", True))
                  If Isempty(sourceDbNameReturn) Then    'Means they hit Cancel
                        Msgbox("Operation cancelled: Unable to continue without a filename.")
                        Exit Sub
                  End If
                  sourceDbName=SourceDbNameReturn(0)
            Else  
                  sourceDbServer = Inputbox("Enter the name of the Domino server")
                  sourceDbName = Inputbox("Enter the filename of the database relative to the server data directory")
                  If sourceDbName = ""  Then  
                        Msgbox("Operation cancelled: Unable to continue without a filename.")
                        Exit Sub
                  End If                  
            End If
            If Not (sourceDb.Open(sourceDbServer, sourceDbName)) Then
                  Msgbox("Unable to find/open file: " + sourceDbName)
                  Exit Sub
            End If
      End If
      
' get destination database
      destDbType = w.Prompt(PROMPT_OKCANCELLIST, "Destination Database",  _
      "Select the location of the database you would like to copy documents/folders to", _
      choices(1), choices)
      
      If destDbType = "" Then
            Messagebox "Operation cancelled"
            Exit Sub
      End If
      If destDbType = choices(0) Then
            Set destDb = s.CurrentDatabase
      Else
            If destDbType = choices(1) Then
                  destDbServer = ""
                  destDbNameReturn = w.OpenFileDialog(False, _
                  "Please select the database you would like to copy from", "*.nsf", _
                  s.GetEnvironmentString("Directory", True))
                  If Isempty(destDbNameReturn) Then  'Means they hit Cancel
                        Msgbox("Operation cancelled: Unable to continue without a filename.")
                        Exit Sub
                  End If
                  destDbName=destDbNameReturn(0)
            Else
                  destDbServer = Inputbox("Enter the name of the Domino server")
                  destDbName = Inputbox("Enter the filename of the database relative to the server data directory")
                  If destDbName = ""  Then
                        Msgbox("Operation cancelled: Unable to continue without a filename.")
                        Exit Sub
                  End If
            End If
            If Not (destDb.Open(destDbServer,destDbName)) Then
                  Msgbox("Unable to find/open file: " + destDbName)
                  Exit Sub
            End If
      End If
      
      If destdb.server=sourcedb.server And destdb.filename=sourcedb.filename And destdb.filepath=sourcedb.filepath Then
            Msgbox("Source and Destination database should not be the same database")
            Exit Sub
      End If
      
' Build collection of all documents in source database using selection
' formula similar to that used in the Mail templates All Documents view
      AllDocsSelect = "@IsNotMember(""A""; ExcludeFromView) & IsMailStationery != 1" +  _
      "& Form != ""Group"" & Form != ""Person"""
      Set AllDocs = sourceDb.Search(AllDocsSelect, Nothing, 0)
      
 ' display progress
      docCount = AllDocs.Count
      current = 0
      Print Cstr(Round(current / docCount * 100, 0)) + "% copied"
      
' step through each folder in source database except system folders other than Inbox
      Forall folder In sourceDb.Views
            If folder.IsFolder And (Instr(1, folder.Name, "(", 0)<>1 Or folder.Name="($Inbox)") Then
                  
' The following code ensures that folders with no docs in them still get copied
'  so that any folder design customizations are kept
                  Set destFolder = destDb.GetView(folder.Name)
                  If destFolder Is Nothing Then
                        Set sourceFolder = sourceDb.GetDocumentByUNID(folder.UniversalID)
                        Call sourceFolder.CopyToDatabase(destDb)
                        Set destFolder = destDb.GetView(folder.Name)
                        If destFolder Is Nothing Then
                              Msgbox("Unable to create folder in new database.")
                              Exit Sub
                        End If
                  End If
' cycle through each doc in the current folder
                  Set sourceDoc = folder.GetFirstDocument
                  While Not (sourceDoc Is Nothing)
                        Set destDoc = sourceDoc.CopyToDatabase(destDb)
' copy each document to the same folder in the destination database
                        Call destDoc.PutInFolder(folder.Name, True)
' remove document from the collection of docs built from source db all docs view
                        Set tempDoc = AllDocs.GetDocument(sourceDoc)
                        Set sourceDoc = folder.GetNextDocument(tempDoc)
                        
                        Call AllDocs.DeleteDocument(tempDoc)   'remove from collection
' display progress
                        current = current + 1
                        Print Cstr(Round(current / docCount * 100, 0)) + "% copied"
                        
                  Wend
                  
            End If
      End Forall
      
' docs remaining in collection are not in any folder - copy these to dest. db
      Set sourceDoc = AllDocs.GetFirstDocument
      While Not (sourceDoc Is Nothing)
            Call sourceDoc.CopyToDatabase(destDb)
' display progress
            current = current + 1
            Print Cstr(Round(current / docCount * 100, 0)) + "% copied"
            Set sourceDoc = AllDocs.GetNextDocument(sourceDoc)
            
      Wend
'done
      Msgbox("Documents have been copied.  Close and reopen the destination file (if it is open) so that it can be refreshed.")
End SubStart Free Trial
[+][-]12.20.2007 at 07:14AM PST, ID: 20507184

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.20.2007 at 09:10AM PST, ID: 20508232

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.20.2007 at 09:14AM PST, ID: 20508265

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.20.2007 at 12:22PM PST, ID: 20509605

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.20.2007 at 08:47PM PST, ID: 20511771

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.23.2007 at 04:24PM PST, ID: 20523002

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Lotus Domino Email Server, Lotus Notes
Tags: adt, argument, lotus, notes, error
Sign Up Now!
Solution Provided By: behenderson
Participating Experts: 5
Solution Grade: A
 
 
[+][-]12.24.2007 at 09:27AM PST, ID: 20525298

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.24.2007 at 10:55AM PST, ID: 20525568

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628