"unable to change views in this context"

Hi,Sometimes, I receive this error message when I try to change the view on my workspace.

This is the code :

Set uidb = uiwork.CurrentDatabase

Call uiwork.SetTargetFrame( “princ” )

Call uidb.OpenView(docSearch.perd_Folder(0),False,False)

In some case it does work properly.

I don’t understand.

Have any idea ?

Thanks in advance.

Subject: “unable to change views in this context”

it might be helpful if you gave examples of when it does and does not work.

Subject: RE: “unable to change views in this context”

Sure, but is it difficult il this case.However now I have found a solution even if I do not understand why it work.

I have a frameset with 3 frames. In one of this frame there is an outline that mapping some view and some folder.

From a button :

  • If I call directly a script library that contains the “openview” method, I receive the message in subject.

  • Otherwise if i call an agent that call the same script library, it does work correctly.

!?!?!

Thanks for the interest.

Daniele.

Subject: RE: “unable to change views in this context”

I found this post after I struggled with this same problem. I too found this to work as Daniele said. I had a shared action button on the view menu, but the script in the action would fail with the openView method. However, setting the action to call an agent and putting the actual script in the agent allowed the openview method to work without the error. This was useful to me to be able to switch views within the framesets (a nice feature).

Also, note the use of all 6 editDocument parameters. If the “return UIDocument” (5th parameter) is set to True or omitted, the script will also fail with the “Target frame is an ancestor of script object” error regardless of the script in an action or agent.

Sample code for reference:

Call ws.setTargetFrame(“Content Frame”)

				Call ws.currentDatabase.OpenView( "NewView", "", False, True)

				Call ws.CurrentView.SelectDocument( docToSelect )		

				Call ws.setTargetFrame("blank")

				Call ws.editdocument( False, docToSelect, False, "", False, True)  

Hope this helps others.

Randy Simms