Notes Error - Target frame is ancestor of script object

I have a frameset and on it I have a frame. In this frame I have a new document. On this document I have a save button.

What I want is when I hit the button it saves and closes this document and opens a new UI document of the same form in the same frame.

As it is now I get the “ancestor” error, and I can understand why, but I can not figure out what to do about it.

Using ws.SetTargetFrame immediately after Dim ws As New NotesUIWorkspace did not work. Again understandably.

— LS code from button —

Sub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Call ws.SetTargetFrame("frameNewDoc")



Set uidoc = ws.CurrentDocument

Call uidoc.Save

Set uidoc= Nothing

Call ws.ComposeDocument( "", "", "formDoc" )

End Sub


Ideas?

Subject: Notes Error - Target frame is ancestor of script object

There is an optional parameter on the ComposeDocument method to return the NotesUIDocument object. Try setting that to false and see if that stops the error from occurring.

Hope that helps.

Subject: RE: Notes Error - Target frame is ancestor of script object

Thanks Wing… Its working by setting last parameter as false…Wow…

Subject: RE: Notes Error - Target frame is ancestor of script object

Try putting the code in an agent and have the action run the agent. If Brandt’s idea doesn’t work.

Subject: SOLUTION

That’s the solution.Thanks, Andre.

I had a similar problem to open a document by UNID from a button which is in the same frame.

→ I put LotusScript code to open the document in an agent.

→ Simply put @Command([ToolsRunMacro];“youragent”) in the button.

@Formula has some nasty drawbacks, especially when working with frames. I understand when people prefer LotusScript.

Subject: OTHER SOLUTION

This code open the uidoc in new tab or window and not show ‘Target frame is ancestor of script object’ message. This is my solution:

Call ws.SetTargetFrame(“”)

Set uidoc = ws.EditDocument( false, doc )

Subject: RE: OTHER SOLUTION

This worked for me, thanks Alfredo.

Subject: Notes Error - Target frame is ancestor of script object

Have you tried using formula language? You can pull this off in formula language by using @SetTargetFrame. I use the technique to bring up pages that say whether the submission was successful or not…

hth.

Brandt