Help: Close InfoPath window in OnLoad Event - InfoPath Dev
in

InfoPath Dev

Help: Close InfoPath window in OnLoad Event

Last post 10-06-2005 09:46 PM by innovision. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 10-05-2005 03:43 AM

    Help: Close InfoPath window in OnLoad Event

    Hi:

    I have a problem about closing InfoPath window. I want only some authorized people can open my InfoPath template. So I think maybe I can put some check codes in the onload event and if user is not permitted to see the form, the InfoPath window will close.

    I have read some topics in the forum about close InfoPath form. In summary there are 3 ways:

    1. Application.Quit().
    Quit method is only used in a fully trusted form. It is not feasible for me.

    2. Application.ActiveWindow.Close()
    It seems this function doesn#%92t work in the onload event. I know Close() can only be used with the OnSubmitRequest and OnClick event handlers. So I add XDocument.Submit() in the onload event and put Close() in the OnSubmitRequest event. But it responds a COMException “Invalid context for the OM call”. If I use a submit button on the form to invoke OnSubmitRequest event, the Close() will work well. Why?

    3. XDocument.View.Window.Close()
    It never works. Shame on me.

    So how to use Close() when the form has not been seen?

    Help me please! Thanks in advanced!
  • 10-05-2005 06:15 AM In reply to

    Re: Help: Close InfoPath window in OnLoad Event

    How is your InfoPath form determining whether or not some one is authorized to open the form? Password protection? Windows Authentication? If you're using Windows Authentication you could just set the permissions for the file or folder that the form is in to allow only a certain group read/execute permission. Also, there is something with InfoPath where you can digitally sign the document and require people to have certificates, but I'm not sure how this works.

    ---------------
    Matt Faus
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 10-05-2005 07:38 AM In reply to

    Re: Help: Close InfoPath window in OnLoad Event

    Hi,

    One possible way to accomplish what you are trying to do is to have your form defaulting to a View where you check your user credentials (Login View). If your user passes your test (use name / passord, etc.), you can then Switch View and go to what you currently have as a default View in your form. Else, you can safely warn your user and close the form...

    Hope that it helps.

    Regards,

    Franck Dauché
  • 10-05-2005 02:34 PM In reply to

    Re: Help: Close InfoPath window in OnLoad Event

    Thanks!

    But, authorization is not the problem here. It is more complicated than password or Windows Authentication.

    Is there no way to close form when opening it?
  • 10-05-2005 06:09 PM In reply to

    Re: Help: Close InfoPath window in OnLoad Event

    well...to my knowledge you can't close the form during the OnLoad event, not during the OnSwitchView event either...
    May have to wait until the OnContextChange event is fired to attempt anything...

    Greg, Patrick, any thoughts in that issue?

    Franck Dauché
  • 10-06-2005 11:15 AM In reply to

    Re: Help: Close InfoPath window in OnLoad Event

    Hi Innovision and welcome to our forum,
    I think it's bad practice to close the window on open since it could lead to a flashing behavior and bad user experience - i.e. they won't understand what happened. Better to switch them to a view and say "You don't have access to this form" or something like that. You'll want to disable save to prevent one mechanism for viewing the XML. This should be quite doable via User Roles and Open Rules (check out tabs on Tools->Form Options in the InfoPath designer) and it is a good design to do this since it explains to the user why they can't see the data. Good luck!

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 10-06-2005 09:46 PM In reply to

    Re: Help: Close InfoPath window in OnLoad Event

    Thank you very much~~~

    Your advice is very useful.
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.