Updating parent with links

I have a main document with a submit button that calls an agent. The agent loops a field for values and creates a new response document for each value - then puts a link to the response in a rich text field. After appending to a richtextitem all the links, I do a doc.Save. The agent then goes on to set a couple more fields. If I close the document it prompts for a save. If i save it, my RT field no longer retains the links I created. If I close and don’t save, the next time I re-open the doc, the links are present.

I’ve tried uidoc.Save, uidoc.Reload, uidoc…

If I do any processing to the document, I lose my links, and I can’t get them to stick.

Has anyone seen anything like this before? I’d be interested in your thoughts.

Thanks - JD

excerpt:

create the rti:

Set doc1 = uidoc.Document

Set rtitem = New NotesRichTextItem( doc1, “responsedoclinks” )

create the responses:

Set doc2 = New NotesDocument(thisdb)

Call doc2.MakeResponse(doc1)

Call doc2.Save(False, True)

place a link on the parent:

Call rtitem.Appendtext("Application Doc: " & doc2.applicationname(0)& " → ")

Call rtitem.AppendDocLink(doc2, "Application doc: "& doc2.applicationname(0))

Call rtitem.AddNewline(1)

save it

doc2.Save(True,False)

------ actually works OK if I manually close the document (escape key)

Include this procedure inside more code:

Call createresponse

Call uidoc.FieldSetText(“Activity”, “Submitted”)

Call uidoc.FieldSetText(“Status”, “Sent”)

Call uidoc.Save()

Call uidoc.Close()

this will lose the links

Put the lniks code behind a button I get the case where if I close with escape key - it prompts for a save - If I say Yes - I lose the links - If I say No - the links are still there!

Subject: I know RT items require close and open

I probably should have added that I am aware that RT chages made in the back end will not appear until the uidoc is closed and re-opened.

This problem was originally encoutered when trying to do the close and re-open with and without the saves.

Subject: RE: I know RT items require close and open

It’s the sequence that’s hurting you. A uidoc.Save (or clicking Save) after the RT updates wipes out your changes.

So:

  1. uidoc.Save

  2. uidoc.Close

  3. do your RTitem updates and doc.Save

  4. then repoen your uidoc

Subject: RE: I know RT items require close and open

Thanks Stephen - turns out that’s exactly what I’m trying now - I just can’t get rid of that pesky prompt “Do You Want To Save”

Call uidoc.Save()

Call uidoc.Close()

Call CreateResponses(session, ws, db, uidoc)

If I can determine where this final prompt is coming from - I might actually have this

ugghhhh

Subject: Solved: doc was in edit mode

if anyone is watching…

altering th sequence did help - but a save prompt was still popping — taking the doc physically out of edit mode was required !!

Does anyone know why?

???

Call uidoc.Save

uidoc.EditMode = False

Call uidoc.Close

Call CreateResponses(session, ws, db, unidD)

Exit Sub

Subject: RE: Solved: doc was in edit mode

My guess is you had a computed field, that recalculates after the save, then wants to save again.

The alternative I have used is:

uidoc.Save

doc.SaveOptions = “0” 'force no save

uidoc.Close

doc.RemoveItem “SaveOptions”

'… other changes

doc.Save true, false

Subject: RE: Solved: doc was in edit mode

Ah - that little snippet is very helpfulThanks Stephen for the help and for following this thread with me

Cheers - JD