Reset data fields - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Reset data fields

Last post 02-05-2009 02:33 AM by Vedran. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-04-2009 06:10 AM

    Reset data fields

    Hi all,

     I have made custom form and logic is this... I have three views: "Main", "Detail" and "New Record" views. On my "Main View" I have query fields and 2 data fileds (Title and Status). Additionaly I put a "See-details" button which opens a Detail view. Also, I have a "Add new record" button which function is to switch to New Record view and open empyt data fields that can be filled.

    The problem is when I query for something and after click on "Add new record" the fields are populated with entries that were returned by the previous query.

    I tried to run some bogus query (query that returns nothing), but then there are no fields showing.

    Is there any way to reset the data fields? To clarify things more, I need fields to be as when first opening the form.

  • 02-04-2009 07:50 AM In reply to

    I just created a new database bound form template, and a New Record button is included by default. That button has an action of 'New Record', which I believe will do what you want. However, that won't allow you to also switch views.... I wonder if instead of using different views, if you might be able to use conditionally formatted sections to provide the same effect without needing to switch views? Then you could use the New Record action....

    Hilary Stoupa

  • 02-04-2009 08:01 AM In reply to

    That is one way to go. Thanks for advice. One question pops in my head right away, how can I define that one section becomes visible if a button in clicked?

    Back to the problem... I'm interested in writing a code behind button that will switch view and reset fields. Is that possible?

  • 02-04-2009 01:41 PM In reply to

    Well, and that is part of the problem with the 'New Record' button -- can't add any other actions to it. But, in general, you can add either a field to your main data source or add a secondary data connection to an XML file and then set a value in that field that you can base your conditional formatting on -- for example, set a field to true() on a button click and have a section set to show or hide if the field is equal to true().

    Definitely you can switch views in code (C#):

    this.ViewInfos.SwitchView("name of view");

    To replicate the New Record, though... I think what you'd need to do is remove all the repeating groups in your data source, then create a new blank one (cloning from sampledata.xml works well....). This would give you a single, blank group. However, I'm not certain what all the New Record action does, so you would want to carefully test Submit and so forth if you take that route...

    Hilary Stoupa

  • 02-05-2009 02:33 AM In reply to

    Hilary Stoupa:

    Well, and that is part of the problem with the 'New Record' button -- can't add any other actions to it. But, in general, you can add either a field to your main data source or add a secondary data connection to an XML file and then set a value in that field that you can base your conditional formatting on -- for example, set a field to true() on a button click and have a section set to show or hide if the field is equal to true().

    Here's the problem if I take "Conditional formatting approach":  if I go to the Add New view first it works ok.  If I run any query, then try to go to the Add New view, the Add New view opens with all the data from the query, one item after another. As you can see, the problem with populated fields remains. :(

    Is it possible to make new form just for entering a new record and merge it with existing one?

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.