Set main datasource - InfoPath Dev
in

InfoPath Dev

Set main datasource

Last post 06-18-2009 03:30 PM by Hilary Stoupa. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 06-16-2009 04:26 AM

    • bryanm
    • Not Ranked
    • Joined on 04-05-2009
    • Posts 6

    Set main datasource

    Hi, is there any way to change an existing form to receive data into its main datasource from a web service

    Similar to the when you add a new template and specify web service?

    I can only seem to add secondary datasources

  • 06-16-2009 06:33 AM In reply to

    Did you try "Convert to Main Data Souce" on a Secondary data source?

    You typically want to build the form from scratch with your new main data source, because it builds the whole schema around the web service (or db schema).  However, doing this locks your main data source, and you can't add or change it, so a secondary data source is sometimes better.

  • 06-16-2009 07:06 AM In reply to

    • bryanm
    • Not Ranked
    • Joined on 04-05-2009
    • Posts 6

    I have one person laying out forms, I then want to add the scondary datasource, this lets me still add fields for performing filters etc. if I convert , I cannot filter

    My problem with this approach is that when the user saves the form as xml, it doesn't save the secondary datasources, also can you submit the secondary datasource using the form submit?

  • 06-16-2009 08:54 PM In reply to

    bryanm:
    My problem with this approach is that when the user saves the form as xml, it doesn't save the secondary datasources, also can you submit the secondary datasource using the form submit?

    Wait, what are you saying here?  When a user saves the form as xmo, it doesn't save the secondary datasources?  What do you mean?  Data sources are only relevant to the template (XSN).  The resultant XML file generated by submitting a form from the template has no relevance to data sources.  It is just an XML file that renders in a special way to us based off the template it's associated with.  So, what do you mean when you say that a submitted (saved) form doesn't "save" secondary datasources?  And what are you asking with the last question?  You don't submit datasources.  Data sources are the source of data for the form template, and the XML of the form is either retrieved from or sent to the data source, depending on what kind of data source it is.

  • 06-16-2009 10:44 PM In reply to

    • bryanm
    • Not Ranked
    • Joined on 04-05-2009
    • Posts 6

    Lets say I have a bunch of fields on the form template that are bound to a field on a secondary datasource (they are working offline)

    If the user saves the form to an xml file, it includes the data in the main datasource, but not the data in the secondary datasource, so when they reopen the form (from the xml), their changes in the example above will be lost

  • 06-16-2009 11:27 PM In reply to

    Oh, so are we talking about offline form usage?  I had not seen that mentioned.  That is a major piece of info in this discussion...

    What IS your secondary data source exactly?

    Is it set to store the data in the form for offline use?

    What are these "changes" that you say are lost?

  • 06-18-2009 03:30 PM In reply to

    I wonder if controls bound to the secondary data source have been placed on the form and the poster thinks that the data entered into those controls will be saved?

    InfoPath will only store data in its main data source. If you have a user making changes to fields that are bound to your secondary data connection, those changes will not be saved -- unless you use code or have another method to save the changes information back to the original data source that the secondary data source was created off of.

    I realize that maybe doesn't make a lot of sense the way I described it... so if we look at a hypothetical example...

    Let's say you've added an XML file to your form as a resource and are using it for a secondary data source in your form. It looks like this:

    <?xml version="1.0" encoding="utf-8"?>
    <Items>
        <Item>
            <ID>1</ID>
            <Name>Paper</Name>
        </Item>
        <Item>
            <ID>2</ID>
            <Name>Toner</Name>
        </Item>
        <Item>
            <ID>3</ID>
            <Name>Drum</Name>
        </Item>
    </Items>

    If you added controls to your form -- let's say a repeating table bound to the 'Item' group... with fields bound to 'ID' and 'Name' -- and a user added a new row to the table, that would not be saved with the filled out form was saved. InfoPath will not automagically add the new 'Item' group to the XML file, or the new 'ID' or 'Name' nodes. In fact, when you open the template again to create a new form, you'd want that XML file to have exactly the original entries, wouldn't you? Otherwise, each time a user added something, if it was written back to the secondary data source, the new thing would show in the next form.

    So, in general, if you want data to stay with the XML created when you use a template, you need to add fields to your main data source for that info. If your form is built off a database, you can still add fields, you just need to add them at the root.

    If you want instead for the user's information to be added to the secondary data source so that every other user who next uses the form has the same data available to them, you can use code to submit the new data to the data source, or to write it to the XML file, or what have you.... but I don't think that is probably what you want...

    Hilary Stoupa

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