Not Allowing Overwrite - InfoPath Dev
in

InfoPath Dev

Not Allowing Overwrite

Last post 05-09-2006 12:25 PM by CycleFitness. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-09-2006 11:17 AM

    Not Allowing Overwrite

    Hello everyone:

    I'm visiting again the issue of using Code and how it supercedes the error trapping built into InfoPath. I have to use Code to use the Application.ActiveWindow.Close(true) function so InfoPath closes once the form is submitted. With that said, if I have the submit data connection set to not allow overwrite, InfoPath gives the user a JavaScript error message if they're trying to overwrite the form. How to I intercept that condition and present a message telling the user they've already submitted the form?

    Currently, my code looks like this:

    {
    if (XDocument.Errors.Count > 0)
    {
    XDocument.UI.Alert("Required information is missing as indicated by the red asterisk(s).")
    return;
    }
    XDocument.Submit()
    Application.ActiveWindow.Close(true);
    }

    Thanks!
    Deb
  • 05-09-2006 12:04 PM In reply to

    Hi Deb,

    A situation such as this is why the try...catch block was invented! Try this out, and for further info seehttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/b7a0a54e-dfaa-4e41-bf25-bcaa43e601fb.asp

    {
    if (XDocument.Errors.Count > 0)
    {
    XDocument.UI.Alert("Required information is missing as indicated by the red asterisk(s).")
    return;
    }
    try
    {
    XDocument.Submit()
    }
    catch(e)
    {
    XDocument.UI.Alert( "Sorry, the form has already been submitted." );
    Application.ActiveWindow.Close(true);
    }
    }
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-09-2006 12:24 PM In reply to

    Hmmm ... I entered the code as follows:

    function CTRL19_5::OnClick(eventObj)

    {
    if (XDocument.Errors.Count > 0)
    {
    XDocument.UI.Alert("Required information is missing as indicated by the red asterisk(s).")
    return;
    }
    try
    {
    XDocument.Submit()
    }
    catch(e)
    {
    XDocument.UI.Alert("Sorry, the form has already been submitted.");
    Application.ActiveWindow.Close(true);
    }
    }

    I enter information that would cause the submit error (filename already exists) and when I click the button nothing happens. I tested to confirm the trap for required fields still works and it does. It seems something about the catch isn't working.
  • 05-09-2006 12:25 PM In reply to

    Sorry, Matt. I had mistakenly checked the "allow overwrite" checkbox. The function works perfectly! This forum is so awesome!

    Thank you, Matt!
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.