Clearing the current form - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Clearing the current form

Last post 08-05-2005 06:03 PM by Agni Jonnalagadda. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 08-04-2005 01:43 PM

    • smaur
    • Not Ranked
    • Joined on 06-17-2005
    • Posts 19

    Clearing the current form

    I have a button on my form to switch views with code behind it per below:

    XDocument.View.SwitchView("RequestInput");

    When you click the button, the fields are prepopulated with data from the previous query, this is fine for most cases, but for this particular button I want the user to be able to access a view where they can input a new record. How do I clear this existing data programatically allowing the user to work on a New Record where all the fields are blank?

    If I use the "New Record" action in the Button Properties dialog a dialog box pops up warning the user "This action will delete all information on the current form", and then the have to click yes to continue.

    I would like this "RequestInput" form to come up without being prepopulated, and without the user having to deal with the warning dialog box.
    Thanks.
  • 08-04-2005 10:23 PM In reply to

    Re: Clearing the current form

    Hi Smaur,
    You are obviously using code. How about just using code to clear the DOM?

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 08-05-2005 05:36 AM In reply to

    • smaur
    • Not Ranked
    • Joined on 06-17-2005
    • Posts 19

    Re: Clearing the current form

    Hi Patrick,
    Thanks for you reply
    Yes That is what I'd like to do, but I'm new to jscript. There is data from two tables on the form, and I was hoping there was a simple way without having to clear each field individually. I tried the code below, tho it didn't seem right, hoping the error msg would give more clues:
    var objXMLNode;
    objXMLNode = XDocument.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:tblRequests/@ReqID");
    XDocument.View.SelectNodes(objXMLNode);

    error message is:
    "Either the combination of values for the View.SelectNodes call is an invalid selection, or the values are not defined for this view, defined for this view more than once, or not selectable in the view."
    Thanks again

  • 08-05-2005 09:22 AM In reply to

    Re: Clearing the current form

    Hi Smaur,
    attributes are not sets of nodes, right? If you remove the "/@ReqID" from your XPath what do you get?

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 08-05-2005 10:22 AM In reply to

    • smaur
    • Not Ranked
    • Joined on 06-17-2005
    • Posts 19

    Re: Clearing the current form

    Patrick,
    Thanks,
    that makes more sense, but it still does'nt clear the fields. Although it took care of the error message.
    The resulting effect is that the entire form is highlighted, but the data remains.
  • 08-05-2005 11:50 AM In reply to

    Re: Clearing the current form

    Hi Smaur,
    The values that you want to empty are in the attributes, and you are trying to empty the nodes which donot have any data.

    Try to replace whole of the node with totally new one, with the help of code.

    Agni
    InfoPath Dev India
  • 08-05-2005 12:31 PM In reply to

    • smaur
    • Not Ranked
    • Joined on 06-17-2005
    • Posts 19

    Re: Clearing the current form

    Hi Agni,
    I've spent the better part of the day trying to figure this one out, I'd appreciate a little more guidance on what that code should look like.
    Thanks
  • 08-05-2005 06:03 PM In reply to

    Re: Clearing the current form

    Hi Smaur,
    There are many similar posts on this site, you can search for replace keyword.
    Or you can modify the code inhttp://www.infopathdev.com/forums/topic.asp?TOPIC_ID=552
    to suit your needs.

    Agni
    InfoPath Dev India
Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.