Lotus Notes Error Function Requires A Valid Adt Argument
Script Notes V4; Notes; Workstation/Desktop; Application Development; LotusScript; Function Requires a Valid ADT Argument" Running a Script; error message; loops; delete documents Technote (FAQ) Question In the Notes client, when you run a script that loops through and deletes documents (such as the sample script below), the following LotusScript run-time error occurs: "Function Requires a valid ADT argument" Sample Script: Sub Initialize Dim s As New NotesSession Dim db As NotesDatabase Dim doc1 As NotesDocument Set db = s.currentdatabase Dim col As NotesDocumentCollection Set col = db.AllDocuments Set doc1 = col.getfirstdocument Do Until (doc1 Is Nothing) '...Do Something to doc1... Call doc1.remove(True) Set doc1 = col.getnextdocument(doc1) Loop End Sub Answer The error occurs because a line (such as the one below) refers to a NotesDocument object (in this case doc1) that was previously deleted from the database. Set doc1 = col.getnextdocument(doc1) In order to loop through and delete documents using script, you should use two NotesDocument variables. For example, the following agent script will successfully loop through and delete all documents in the current database. Sub Initialize Dim s As New NotesSession Dim db As NotesDatabase Dim doc1 As NotesDocument Dim doc2 As NotesDocument Set db = s.currentdatabase Dim col As NotesDocumentCollection Set col = db.AllDocuments Set doc1 = col.getfirstdocument Do Until (doc1 Is Nothing) '...Do Something to doc1... Set doc2 = col.getnextdocument(doc1) Call doc1.remove(True) Set doc1 = doc2 Loop End Sub Cross reference information Segment Product Component Platform Version Edition Messaging Applications IBM Notes Lotus Notes Linux, Mac O
Training Support Forums & community Events Rational Tivoli WebSphere Java technology Linux Open source SOA and Web services Web development XML My developerWorks About dW Submit content Feedback developerWorks>Lotus>Forums & community>Notes/Domino 4 and 5 Forum Notes/Domino 4 and 5 Forum Function requires a valid ADT argument (using collection.getnextdocument) Function requires a valid ADT argument (using collection.getnextdocument)Posted by Leena Watie on 10.Apr.03 at 10:21 PM using a Web browserCategory: Domino Designer -- LotusScriptRelease: 5.0.1aPlatform: Windows 2000 http://www.ibm.com/support/docview.wss?uid=swg21093032 Hi everyone, I get the error "Function require a valid ADT argument" whenever I reach the line: Set doc = dc.getnextdocument (doc) I understand that normally this error occurred when you are trying to getnextdcument from the document that you have just deleted. But I have already put the temporary variable to keep the document value and http://www-10.lotus.com/ldd/46dom.nsf/ReleaseAllThreadedweb/206d9da612b2ebd285256d05000cfe29?OpenDocument also get the handle of the next document. Can somebody tell me why I'm getting this error? Really appreciate any kind assistance. Thanx in advance. -leena- Sub Initialize On Error Goto Trap Dim s As New NotesSession Dim uiws As New notesuiworkspace Dim StringTable As New mailtoolsstringtable Dim db As NotesDatabase Dim dc As NotesDocumentCollection Dim doc As NotesDocument Dim newDoc As NotesDocument Dim ndb As NotesDatabase Dim doc1 As NotesDocument Dim docc As NotesDocument Dim Start As Integer Dim One As String Dim Two As String Dim view As Notesview Dim temp As String Set db = s.CurrentDatabase Set dc = s.currentdatabase.unprocesseddocuments Set doc = dc.getfirstdocument While Not (doc Is Nothing) Forall subject In _ doc.GetItemValue ("Subject") Set view = db.Getview ("AAR") Set docc = view.getfirstdocument While (Not docc Is Nothing) Forall conditionlistdisplay In docc.ConditionListDisplay Start = Instr(1,conditionlistdisplay,"$") One = Left(conditionlistdisplay,Start-1) Two = Right(conditionlistdisplay,Len(conditionlistdisplay)-Start) If Instr (1,subject,One,5) And Instr (1,subject,Two,5)<> 0 Then Set ndb = s.Getdatabase ("","mail\test.nsf") Forall folder In docc.folder Call ndb.EnableFolder (folder) Set newDoc =
Training Support Forums & community Events Rational Tivoli WebSphere Java technology Linux Open source SOA and Web services Web development XML My developerWorks http://www-10.lotus.com/ldd/46dom.nsf/869c7412fe5d56b7852569fa007826e3/eb40ab1cdbe82c9f85256a560031b4aa?OpenDocument About dW Submit content Feedback developerWorks>Lotus>Forums & community>Notes/Domino 4 and 5 Forum https://www.experts-exchange.com/questions/23035882/Error-Function-Requires-a-Valid-ADT-Argument-Running-a-Script.html Notes/Domino 4 and 5 Forum Error 4207:Function requires a valid ADT argument Error 4207:Function requires a valid ADT argumentPosted by Graham Hitchman on 24.May.01 at 05:02 AM using a Web browserCategory: Domino Designer -- LotusScriptRelease: All ReleasesPlatform: Windows 95/98 Whilst trying to use GetNextSibling I get the above error lotus notes message. Does anyone know or has seen this before and what I must do to fix it??? Return to top Error 4207:Function requires a vali... (Graham Hitchman... 24.May.01) . . RE: Error 4207:Function requires a ... (Shel Bowden 24.May.01) . . . . RE: Error 4207:Function requires a ... (Graham Hitchman... 24.May.01) . . . . . . RE: Error lotus notes error 4207:Function requires a ... (Shel Bowden 24.May.01) Document options Print this page Search this forum Forum views and search Date (threaded) Date (flat) With excerpt Author Category Platform Release Advanced search RSS feeds All forum posts RSSAll main topics RSSMore Lotus RSS feeds Resources Forum use and etiquette Native Notes Access Web site Feedback Lotus Support Lotus Support Product support pages index Search knowledge base (Technotes) Search support downloads Lotus Support RSS Wikis IBM Composite Applications IBM Mashup Center IBM Connections IBM Docs IBM Forms IBM Mobile Connect IBM Sametime IBM SmartCloud for Social Business IBM Web Experience Factory Lotus Domino Lotus Domino Designer Lotus Expeditor Lotus Foundations Lotus iNotes Lotus Instructor Community Courseware Lotus Notes Lotus Notes & Domino Application Development Lotus Notes Traveler Lotus Protector Lotus Quickr Lotus Symphony IBM Web Content Manager WebSphere Portal Lotus Forums Notes/Domino 9.0 Notes/Domino 8.5 + Traveler Notes/Domino XPages development forum Notes/Domino 8 Notes/Domino 6 and 7 Notes/Domino 4 and 5 IBM Connections IBM Forms IBM Mobile Connect IBM Sametime IBM SmartCloud Notes IBM SmartCloud Meetings IBM Web Content Manager Lotus Domino Doc
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > Error: "Function Requires a Valid ADT Argument" Running a Script Want to Advertise Here? Solved Error: "Function Requires a Valid ADT Argument" Running a Script Posted on 2007-12-20 Lotus IBM 4 Verified Solutions 8 Comments 2,148 Views Last Modified: 2013-12-18 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 I