There is a button on the document named “Process” When i click on that button an agent.RunOnServer(currentdoc.NoteID) is called. Immediately after agent is executed… mail sending procedure is called and then close the document.
Agent:
Update the records from the current document in Oracle as well in notes.
Query:
Wants to know that whether agent has executed successfuly or not(No error reported) means the whole process in agent has been completed. On the basis of successful execution of agent, mail is send to the user and document is closed.
Thanks.
Regards,
Farroukh
Subject: Agent
Hi
Just to some more idea with Brian response.
If possible you can create a log kinda stuff to check whether agent has executed successfuly or not.
Piyush
Subject: RE: Agent
any suggestion piyush as how can i create a log file or something to track…
Thanks in advance.
Regards,
Farroukh
Subject: Agent
Two suggestions:
One - separate the process to two agents and have the first agent call the second agent upon successful completion. If you need to pass the document from the first agent to the second agent, you can do so like this:
First Agent
Set agent = db.GetAgent("Send Notification E-mail")
Call thisDoc.Save(True,True)
If agent.Run(thisDoc.NoteID) = 0 Then
Messagebox "Incident number " + newNumber + " has been created",MB_OK ,"Confirm "
Else
End If
Second agent
Dim session As New NotesSession
Dim agent As NotesAgent
Set agent = session.CurrentAgent
Dim db As NotesDatabase
Set db = session.CurrentDatabase
'Get the document passed by the calling agent
Dim doc As New NotesDocument(db)
Set doc = db.GetDocumentByID(agent.ParameterDocID)
id2 = doc.UniversalID
Two - use the Notes Agent class to send the E-mail to the user. When the log is closed, it generates a memo to the specified address in the open command. Example:
Dim currentlog As New noteslog("debug agent")
Dim session As New NotesSession
Dim agent As NotesAgent
Set agent = session.CurrentAgent
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Call currentlog.OpenMailLog("End Username/OU/O", "Agent error log")
Call currentlog.LogAction("Starting...")
Dim server As New NotesName(db.server)
servername = server.Common
Call currentlog.LogAction("What server am I using? " + servername)
path = Left(db.filepath , 4)
filename = db.filename
Gosub CreateTheMail
Call currentlog.LogAction("Completed CreateTheMail")
Gosub PopulateMailFields
Call currentlog.LogAction("Completed PopulateMailFields")
Gosub PopulateRecipients
Call currentlog.LogAction("Completed PopulateRecipients")
Gosub SendTheMail
Call currentlog.LogAction("Completed SendTheMail")
Call currentlog.LogAction("Agent successfully executed")
Call currentlog.Close
Exit Sub
Subject: Agent
Just update the document you pass to the agent, with a result from the agent, and read that value from the button you click…
The button code is:
agent.RunOnServer(currentdoc.NoteID)
In the server agent, you fetch the currentdoc above, and update the document with a status of how the agent completed.
Then after the agent.RunOnServer(currentdoc.NoteID) you can check the currentdoc object for the values you appended in the server agent.
/Brian
Subject: RE: Agent
Until and unless the current document is not closed once, it does not shows the updated value of the currentdoc which were updated in the agent.
and i don’t want to close the document unless the agent has executed successfully.
Thanks in advance,
Regards
Farroukh
Subject: RE: Agent
You could grab the UniqueID of the document, and then just close and reopen it ? Wouldn’t that be an option.
I think I remember doing this a long time ago (I might be wrong :-))… and do not have access to that code anymore.
/Brian
Subject: RE: Agent
Thanks Brian…
but two issues
…
1: If i close that document how would i find that document Unique ID.
2: Lets suppose if somehow i managed to get the Unique ID then where would i write the code to open that document again.
Consideration:
-it is possible that more than one user are performing the same kind of process on different documents.
Regards,
Farroukh
Subject: RE: Agent
Hi again,
this is not a complete code sample… but should give you an idea…
This is code in the button…
Dim sess As New NotesSession
Dim curDb As NotesDatabase
Dim agent As NotesAgent
Set curDb = sess.GetCurrentDatbase
'your code to access the agent goes here
agent.RunOnServer(currentdoc.NoteID)
’ now the agent is executed, and the currentdoc is updated)
’ the agent.RunOnServer(currentdoc.NoteId) actually returns 0 if the agent ran successfully,
’ and returns 1 if the agent didn’t run (If agent.runonserver(currentdoc.noteid) = 1 then msgbox “error”
unid = currentdoc.UniqueID
set currentdoc = nothing
set currentdoc = curDb.GetDocumentByUNID(unid)
’ read the currentdoc object and check values as you normally would
Hope this helps you…
/Brian