LotusScript Agent

Hello,

my Problem is, that I got a NotesDocument, which I want to change and save through the use of an agent (which is running in the web)

Scenario:

I submit a form in the web, then my agent runs from the WebQuerySave Event

I have found the following Code all over the web:

  1. Set session = New NotesSession

  2. Set db = session.CurrentDatabase

  3. Set subDoc = session.DocumentContext

  4. subDoc.avCourseSeats=100

  5. Call matchDoc.save(True, True)

I wanna do exactly the same through my agent, with the exception, that i get my Document from a view. (The Document is available, and i can Print field values and even change field value)

  1. Set session = New NotesSession

  2. Set db = session.CurrentDatabase

  3. Set subDoc = session.DocumentContext

  4. Set vw = db.GetView(“BEVCourseDatesID”)

  5. Set matchDoc = vw.GetDocumentByKey(subDoc.RegCourseDateID(0))

  6. matchDoc.avCourseSeats=100

  7. Call matchDoc.save(True, True)

[av CourseSeats is a number Field]

wenn I replace line 7 through a "Print Cstr(matchDoc.avCourseSeats(0), I get the wanted value, but of course it is not saved.

When I Use the 7 lines of Code above My Browser only Shows “Document processed”

(because of insufficient Rights i am not able to run the web debugger for lotus Script.)

I hope someone of you can help me with that Problem.

Subject: LotusScript Agent

Thank you for your answer.I got the error through some print error statements and the error was quite simple, it was just because of my anonymous acl entry, which didn´t have the rights…

Subject: LotusScript Agent

Not sure why you get the error but you can check the log.nsf file on the server for any errors that occur during the execution of your script. You could also add error handling to handle any errors and either deal with them or print them in the web ui.

I also assume that matchDoc Is Not the same document as subDoc otherwise your changes may get overrwritten when subdoc is submitted / saved.

You should probably add more handling of null values in your code. Here’s an example with revised code:

Set session = New NotesSession

Set db = session.CurrentDatabase

Set subDoc = session.DocumentContext

If Trim(subDoc.RegCourseDateID(0)) <> “” Then

Set vw = db.GetView("BEVCourseDatesID")

If Not vw Is Nothing Then

	Set matchDoc = vw.GetDocumentByKey(subDoc.RegCourseDateID(0), True)

	If Not matchDoc Is Nothing Then

		matchDoc.avCourseSeats=100

		Call matchDoc.save(True, True) 

	End If

End If

End If

Alex