I’m trying to do a simple @Abstract on a document created via XPages when the new document is saved. I have a rich text Body field and when the doc is saved I want to take the first 100 characters of text and save that in a field called bAbstract. I’ve tried several ways but right now I’m running an agent when the XPage is saved which should update the document but it’s not working.
Any help would be greatly appreciated!
As soon as a new XPage is opened, long before the agent is ever run, this error shows up on the server console:
06/14/2010 10:00:00 AM HTTP Web Server: Couldn’t find design note - [object] [/Dev/forum.nsf/%5Bobject%5D]
Here is the code in the postSaveDocument event:
var agent:NotesAgent=database.getAgent(“Agent1”);
agent.run(dominoDocument1.getNoteID());
And here is the code for Agent1. I’ve tried replacing or remming out all the lines in the agent in case there’s something wrong here and I still get the error, so there must be something wrong in the postSaveDocument code.
Sub Initialize()
Dim session As New NotesSession
Dim db As NotesDatabase
Dim agent As NotesAgent
Dim doc As NotesDocument
Dim item1 As NotesItem
Dim item2 As NotesItem
Set db = session.currentDatabase
Set agent = session.currentAgent
Set doc = db.getDocumentByID( agent.ParameterDocID )
Set item1 = doc.GetFirstItem( "Body" )
Set item2 = doc.ReplaceItemValue( "EstimatedCost", item1.Abstract( 100, False, False ) )
End Sub