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 OS, Windows 8.0, 7.0, 6.5, 6.0, 5.0 All Editions Messaging Applications IBM Domino Lotus Domino Server AIX, i5/OS, Linux, Solaris, Windows, z/OS 8.0, 7.0, 6.5, 6.0, 5.0 All Editions Pro
disable Out Of Office agent ooo; agent; out of office; amgr; Function requires a valid ADT argument; when attempting to disable agent; disable agent; disable ooo; disable; disabling; server Technote (FAQ) Question You are connected to a Domino server using a http://www.ibm.com/support/docview.wss?uid=swg21093032 remote console. You attempt to disable an Out Of Office (OOO) agent by issuing the command, "Tell amgr cancel
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 http://www-10.lotus.com/ldd/46dom.nsf/0/bef49777fc18eb0c85256e190083b8b5?OpenDocument Feedback developerWorks>Lotus>Forums & community>Notes/Domino 4 and 5 Forum Notes/Domino 4 and 5 Forum Function requires a valid ADT argument" at CopyItem() method Function requires a valid ADT argument" at CopyItem() methodPosted by Bilal Ahmed on 12.Jan.04 at 06:58 PM using a Web browserCategory: Domino Designer -- AgentsRelease: 5.0.11Platform: Windows 2000 Hi Guys, I have am agent that is scheduled to run when "All New Email error function has arrived", and process the new emails documents as shown below. Actually I am just removing a Body field from the Incoming email document and creating an equivalent field with different name "Amessage". but the agent is throwing "Function requires a valid ADT argument" at CopyItem() Method. Here is the Code, Set collection = db.UnprocessedDocuments For i = 1 To collection.Count Set doc = collection.GetNthDocument( error function requires i ) If Not (doc Is Nothing) Then doc.Processed = "Y" doc.PostedDate = Format(Date, "mm/dd/yyyy") doc.Form = "InboundMemo" 'Rename the body field Set body = doc.GetFirstItem("body") Call doc.CopyItem( body, "AMessage") <--- Error Line doc.GetFirstItem("Body").Remove Call doc.computewithform(False, False) Call doc.save(True, False) Next Please help me out Thanks Return to top Function requires a valid ADT argum... (Bilal Ahmed 12.Jan.04) . . RE: Function requires a valid ADT a... (Morten Hattesen... 13.Jan.04) . . . . RE: Function requires a valid ADT a... (Bilal Ahmed 14.Jan.04) . . . . RE: Function requires a valid ADT a... (Bilal Ahmed 28.Jan.04) 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 Facto