Close Infopath at OnAfterChange Event - InfoPath Dev
in

InfoPath Dev

Close Infopath at OnAfterChange Event

Last post 12-15-2005 01:58 AM by Patrick Halstead. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 12-13-2005 03:38 AM

    • zmike
    • Not Ranked
    • Joined on 12-13-2005
    • Portugal
    • Posts 8

    Close Infopath at OnAfterChange Event

    Hi,again!!
    Is that possible??!!
    To Close Infopath at OnAfterChange Event
    I get always an error:
    Invalid context for OM call.

    I already readed a topic about that....
    But i really need to close the infopath on that event....

    Thanks.

    Miguel Carvalho
    Portugal
  • 12-13-2005 05:15 AM In reply to

    Re: Close Infopath at OnAfterChange Event

    Hi,

    Welcome on Infopathdev.com!

    yes you can in C#:

    thisApplication.XDocuments.Close(0);


    ++

    Thierry
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 12-13-2005 07:04 AM In reply to

    • zmike
    • Not Ranked
    • Joined on 12-13-2005
    • Portugal
    • Posts 8

    Re: Close Infopath at OnAfterChange Event

    Thanks...
    But i am not using nothing in Visual Studio... Only using Microsoft Script Editor.... :(

    This is what gives me the "OM call" error
    Application.XDocuments.Close(0);

    I try other solutions.... But nothing..
    Do I have to create a new project on VS only to solve this situation??!

    Regards,

    Miguel Carvalho
    Portugal
  • 12-13-2005 07:54 AM In reply to

    Re: Close Infopath at OnAfterChange Event

    Hi,

    Ok I understand now!

    Your form need to be full trust!

    Read this:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/ipsdkUnderstandingFullyTrustedForms_HV01073332.asp

    ++

    Thierry
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 12-13-2005 08:43 AM In reply to

    • zmike
    • Not Ranked
    • Joined on 12-13-2005
    • Portugal
    • Posts 8

    Re: Close Infopath at OnAfterChange Event

    mmmmmm!!!!
    i don't know....
    i readed it...

    I do not understand why i use:
    Application.XDocuments.Close(0);
    5 times in the document, and it works.....

    It only do not work OnAfterChange event...
    :(

    And i reealy need that...

    Miguel Carvalho
    Portugal
  • 12-13-2005 12:28 PM In reply to

    Re: Close Infopath at OnAfterChange Event

    That is a little weird. Your form does not have to be fully trusted to use that function. I couldn't find much information on google about anyone else having this problem - maybe you could put your close functionality inside of a button and have a user click it?

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 12-14-2005 01:18 AM In reply to

    Re: Close Infopath at OnAfterChange Event

    Close is level 3 which would imply Full Trust. Check out the SDK.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 12-14-2005 02:27 AM In reply to

    • zmike
    • Not Ranked
    • Joined on 12-13-2005
    • Portugal
    • Posts 8

    Re: Close Infopath at OnAfterChange Event

    Hello again!!
    I already solve the situation... ;)
    I register the Form, Fully Trusted and then use:

    Application.Quit(true); //To not save the form

    It solved, and really quits the Apllication, not only the Form.

    The only thing that is making me sad.. Is that to create a Fully Trusted we need to certificate the form.
    I did it, publish into a Sharepoint library... But then, when users open the form, It asks to approve the certificate, but the checkbox to approve it, is not activate then we can not open the form....
    Can anybody help???

    Thanks in advance! ;)

    Miguel Carvalho
    Portugal
  • 12-14-2005 07:00 AM In reply to

    Re: Close Infopath at OnAfterChange Event

    Weird, I checked the SDK before I claimed that it didn't have to be Full Trust and it said this:


    quote:
    Close Method (XDocuments Collection)
    See Also Applies To Example Specifics
    Closes the specified Microsoft Office InfoPath 2003 form.

    expression.Close(ByVal varIndex As Variant)
    expression Required. An expression that returns a reference to the XDocuments collection.

    varIndex Required Variant. The string value that specifies the Uniform Resource Identifier (URI) of a form, a long integer value that specifies the positional index of an XDocument object within the XDocuments collection, or a reference to an XDocument object.


    Security Level
    2: Can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.


    I know there are other methods that close the form, such as Application.Quit() that are level 3, but I think this is because it closes the entire InfoPath application and all open forms, whereas XDocuments.Close(0) only closes one InfoPath form (which is referenced by the number passed in). For this reason, the XDocuments.Close() method can be safely used without being fully trusted. This is my understanding, please correct me if I'm wrong.

    Anyway, glad you figured it out zmike! Check out this tutorial for publishing signed forms to Sharepoint:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/ipsdkDeployURNFormToSharePoint_HV01086376.asp

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 12-15-2005 01:58 AM In reply to

    Re: Close Infopath at OnAfterChange Event

    You're right though - you don't need Full Trust. I was thinking of Save. ... Sorry ... too sleepy or something. Not thinking straight since we do this all the time.

    In general, you don't want to be Full Trust since it is very limiting and complicates deployment.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.