Simple agent runs but doesn't update documents

I’m really new to LotusScript and don’t know whether my problem is how or where I’m calling my agent. The agent works beautifully when called via formula language. According to the agent log it is triggered without problem. Its just not updating any documents. Thanks in advance for your help.

Sub Querysave(Source As Notesuidocument, Continue As Variant)

'Get a handle on the Notes Session

Dim session As New NotesSession

'Get a handle on the Current NotesUIWorkspace

Dim ws As New NotesUIWorkspace

'Get a handle on the uidoc and underlying document

Dim uidoc As NotesUIDocument

Set uidoc=ws.CurrentDocument

'Get a handle on the current database

Dim db As NotesDatabase

Set db = session.CurrentDatabase

'Assign variables

Dim IssueNum As String

Dim SendTo_1 As Variant

Dim docCurrent As NotesDocument

Set docCurrent = uidoc.Document

Dim tmp As String

Dim Assignees As String

Dim agent As NotesAgent

Set agent = db.GetAgent("Set Sequential Number")

Call agent.run





If docCurrent.Assignees(0) <> docCurrent.tmpAssignees(0) Then

	'Present the dialogbox

	docCurrent.Form = "Memo" 

	Call ws.DialogBox( "dlgTest", True, True, True, False, False, False, "Message Content Only") 

	

	Call docCurrent.save(False, True )

End If



docCurrent.tmpAssignees=""

Set agent = db.GetAgent("Status Cleanup")

Call agent.run

docCurrent.SendTo = docCurrent.Assignees

docCurrent.Subject = docCurrent.Subject_1

docCurrent.Body = docCurrent.Body1



Call docCurrent.send(False)

Call docCurrent.save(False, False )

End Sub

Subject: Simple agent runs but doesn’t update documents

Angie,

What does the agent do that you cannot do in here. You may think the agent has run but it may not have.

Actually you have two agents here? I would not use an agent to assign the sequential number. Did I not give you the ScriptLibrary subroutine to do that?

Also, remeber what I told you about keeping all this code in a button. Yoh really shouoldn’t, but should have the code in a scriipt library that is called.

Also, if it truly is an agent (it should be surrounded by parens:

Dim agent As NotesAgent

Set agent = db.GetAgent(“(Set Sequential Number)”)

Finally, it is hard to know what the problem may be because the agent code is not posted. Go ahead and email me a zipped copy of the DB again…

Subject: RE: Simple agent runs but doesn’t update documents

Hi File Save,Sorry, I intended to place the agent code here but had forgotten. I’ve been able to verify that it runs thru the agent log. Its not a complex agent at all. Oh how I wish everything could be done in Formula language. :slight_smile:

Anyway, to answer your question regarding the ScriptLibrary. Its a great idea but… I’m not there yet in knowing how to create the script library. If I’d worked for this company longer I’d know where to look in different databases for an example but… I haven’t found any examples to look at.

You have brought up an interesting suggestion. Let me try to replace my existing agent with script. It’ll be a great practice exercise.

@If(pctComplete = “100”;@SetField(“reqStatus”;“Complete”) ;

      reqStatus = "Complete";@SetField("pctComplete";"100") ;"")

Subject: RE: Simple agent runs but doesn’t update documents

Angie,

If that is all that you agent is doing, you are killing yourself with too much overhead. It is also looping crazily? Is there ever a case where pctComplete is empty but regStatus=complete and visa versa?

Why is regStatus just not a computed field?

Subject: Simple agent always has a default value

File Save,Both fields always have a default value assigned.

Basically if the task document is 100% complete it should be “Complete” if its 20% its “In Progress” or “On Hold”. If its 0% its “New”.

Then if the document is updated to Complete status but the user forgets to update the percent complete the reverse is true.

Is there a better way?

Thanks