?
Solved

Agent that will update all docs in a database

Posted on 2000-05-11
2
Medium Priority
?
224 Views
Last Modified: 2013-12-18
I'm using the code below to connect to an AS/400 thru an odbc connection. I put this code into an agent and it works fine if I have the document open in edit mode. Is it possible to run the agent from a view and have it update all the documents in the database? When I select a document in a view and run the agent I get an error message "Object variable not set" Looking at this in the lotusscript debugger I can see that it bombs out on the Qry.SQL statement. What am I missing to get an agent to act on every document in the database?





Sub Initialize
      Dim A As String       '*LIMIT STATUS
      Dim H As String
      Dim O As String
      Dim P As String
      Dim S As String
      Dim T As String
      Dim Q As String
      Dim W As String
      
      A = "A"
      H = "H"
      O = "O"
      P = "P"
      S = "S"
      T = "T"
      Q = "Q"
      W = "W"
      
      
      Dim con As New ODBCConnection
      Dim qry As New ODBCQuery
      Dim res As New ODBCResultSet
      
      Dim WS As New notesUIWorkspace
      Dim uidoc As NotesUiDocument
      Dim doc As NotesDocument
      
      Set uidoc = ws.currentdocument
      'Set doc = uidoc.Document
      
      
status=Con.ConnectTo("datasource","id","pw")
If con.geterror<>DBstsSuccess Then
Messagebox con.GetExtendedErrorMessage,,"Could not make connection to AS/400 system"
            Exit Sub
      Else
      End If
      
      Set qry.Connection = Con
      Qry.SQL = "select * from SOFTTURND.TPRJTSK where TRSRC='"+uidoc.fieldgettext("resource")+"'" + "ORDER BY TPTY, TPROJ"
      If qry.geterror<>DBstsSuccess Then
            Messagebox qry.GetExtendedErrorMessage,,"SQL Error"
            con.Disconnect
            Exit Sub
      Else
      End If
      
      
      Set Res.Query = Qry
      
      Res.Execute
      If res.GetError<>DBstsSuccess Then
            Messagebox res.GetExtendedErrorMessage,,"Result Error"
            res.close(DB_CLOSE)
            con.Disconnect
            Exit Sub
            
      Else
            If Not res.IsResultSetAvailable Then
                  Messagebox "No Values Found for your Query"
            Else
                  
                  
                  Dim Counter As Integer
                  Counter = 1
                  
                  Do      
                        Call uidoc.FieldSetText("project_" + Cstr(Counter), "")
                        Call uidoc.FieldSetText("task_" + Cstr(Counter),  "")
                        Call uidoc.FieldSetText("description_" + Cstr(Counter), "")
                        Call uidoc.FieldSetText("requester_" + Cstr(Counter),  "")
                        Call uidoc.FieldSetText("priority_" + Cstr(Counter), "")
                        Call uidoc.FieldSetText("status_" + Cstr(Counter),  "")
                        Counter = Counter + 1                                    
                  Loop Until Counter = 49
                  
                  
                  Counter = 1                  
                  Do
                        res.NextRow
                        
                        If Res.GetValue("TSTS") = S  Or Res.GetValue("TSTS") = H Or Res.GetValue("TSTS") = A Or Res.GetValue("TSTS") = O Or Res.GetValue("TSTS") = P Or Res.GetValue("TSTS") = T Or Res.GetValue("TSTS") = Q Or Res.GetValue("TSTS") = W Then
                              
                              Call uidoc.FieldSetText("project_" + Cstr(Counter), Res.GetValue("TPROJ"))
                              Call uidoc.FieldSetText("task_" + Cstr(Counter),  Res.GetValue("TTASK"))
                              Call uidoc.FieldSetText("description_" + Cstr(Counter),  Res.GetValue("TDESC"))
                              Call uidoc.FieldSetText("requester_" + Cstr(Counter),  Res.GetValue("TRQSTR"))
                              Call uidoc.FieldSetText("priority_" + Cstr(Counter),  Res.GetValue("TPTY"))

Call uidoc.FieldSetText("status_" + Cstr(Counter),  Res.GetValue("TSTS"))
                              
                              
Counter = Counter + 1      
End If
                        
Loop Until res.IsEndOfData Or Counter = 49
                  
                  Counter = Counter - 1
Call uidoc.FieldSetText("count",Cstr(Counter))      
                  
Call uidoc.FieldSetText("date" , Cstr(Date$))
                  
      End If
      End If
      Res.Close(DB_close)
      Con.Disconnect
End Sub
0
Comment
Question by:roosterup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
Arunkumar earned 800 total points
ID: 2802765
Hi Roosterup,

Include these lines to refer doc(The document you select from the view)

Dim ss As New notessession          
Dim db As notesdatabase
Set db = ss.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument

Change all the
Call uidoc.FieldSetText("FieldName",Value) lines to read as

doc.FieldName = Value

MAKE Sure your lines for
Qry.SQL reads as follows

Qry.SQL = "select * from SOFTTURND.TPRJTSK where TRSRC = '"+ doc.resource(0) +"'" + "ORDER BY TPTY, TPROJ"


Also at the end of the script make sure you use the following to save the document

Call doc.Save(True,False)

Good Luck !

-Arun

PS: These Code changes will work for only one document that is selected in the view since we are not looping through documents.
0
 
LVL 1

Author Comment

by:roosterup
ID: 2802855
I would actually like to run this agent on a schedule and have it update all the documents.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question