A Comfortable Couch

Thursday, February 17, 2005

Question for Notes hackers

I got a question from Julian Robichaux about Agent Boost. I think this will become a common use for Agent Boost and I hope I can find him an answer:
The first agent I wrote was to try to log what changed on a document when it gets saved. I set up a "before document is modified or saved" agent that gets two references to the doc: one using session.DocumentContext (the doc that's about to be saved) and one using db.GetDocumentByUNID(bs.UniversalID). Both of these are returning a reference to the in-memory document though.

I was hoping there was a way to get a reference to both the in-memory doc (with the pending changes) and the on-disk doc (without the changes), so I could compare them. Sort of like how you can use either NSFDbGetNoteInfo or NSFNoteGetInfo.

So I guess the question is, do you know of a way to do that within the context of AgentBoost?
I know the problem is the caching behaviour built into the Notes LSXBE object apis, I think I've seen this same problem in other contexts, anyone know solutions to this?

BTW Julian gave me some very helpful feedback on Agent Boost as well. Thanks Julian!

Update: Julian puts more info about the problem on his blog.
Update 2: An answer is found and Julian completes his solution. BTW I'd like to add this to the examples, is that ok Julian?

9 Comments:

Andrew Tetlaw said...

I do this in WebQuerySave agents, I grab the session.DocumentContext, 'doc = s.DocumentContext', copy all the items to another temp NotesDocument object, then do a LS 'Delete doc' on the session.DocumentContext doc.

I can then open the doc from disk again 'db.GetDocumentByUNID()' and the temp doc and the newly opened doc can be compared.

But I'm not sure if it would work in the same way from the Notes UI

6:00 PMlink  
Julian Robichaux said...

This post has been removed by the author.

7:21 PMlink  
Julian Robichaux said...

BTW, here's the agent I was testing with. I just realized I never sent it to you (how rude of me). It could stand some optimization, but it's a start...

http://www.nsftools.com/blog/blog-02-2005.htm#02-17-05

7:23 PMlink  
Anonymous said...

I saw a post somewhere (sorry, cant recall the source). If I remember correctly, they where getting around the same issue by deleting the object handle to the session doc before getting the doc by unid, and then setting the object handle again

doc = s.DocumentContext
unid=doc.universalID
doc=nothing
doc2=db.getDocumentByUNID(unid)
doc = s.DocumentContext

7:25 PMlink  
Julian Robichaux said...

Wow, thanks guys! That was the trick (deleting DocumentContext before getting it by UNID, and then getting it by DocumentContext again).

Updated (and seemingly working) sample agent at: http://www.nsftools.com/tips/AgentBoostLog2.lss

9:35 PMlink  
Julian Robichaux said...

Regarding your update #2: I'd be happy for you to add this as an example if you want. I'll probably hack around with the agent a little more this weekend, so I'll send you any updates I make as well.

5:50 PMlink  
Anonymous said...

Thank you!
[url=http://bdtnaust.com/knmb/roys.html]My homepage[/url] | [url=http://irmuyjfx.com/axsj/knmz.html]Cool site[/url]

11:25 AMlink  
Anonymous said...

Nice site!
My homepage | Please visit

11:25 AMlink  
Anonymous said...

Good design!
http://bdtnaust.com/knmb/roys.html | http://lbxwandm.com/etch/rtxn.html

11:26 AMlink  

Post a Comment

<< Home