New multi-valued repeating tables corrupted after the template update - InfoPath Dev
in

InfoPath Dev

New multi-valued repeating tables corrupted after the template update

Last post 01-06-2011 10:01 PM by Patrick Halstead. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 12-20-2010 10:26 PM

    New multi-valued repeating tables corrupted after the template update

    Hello,

    Some background first to better describe the problem:

    We're using InfoPath to survey many of our users on various subjects, so many of the surveys have repeating tables with pre-defined (default) values and those are locked for additions by user. The regular case is multi-select field (with checkboxes) that provides a list of pre-defined values. For example:

    What is your role in this system:

    [ ] Software developer
    [ ] Regular user
    [ ] Power user
    [ ] Administrator
    [ ] Do not know

    So the user can select several answers.

    The form is published on the SharePoint Forms Library and is filled with the InfoPath Filler.

    We're processing the survey results by variuos analysis tools, that's why having only the true/false values in XML is not enough since we need also to have the exact text that this "check" was set for. Also, we must preserve the compatibility with the InfoPath 2003, that's why we can't use some specific (and convenient) 2007 / 2010 features.

    So, we implement such fields in the following way - we create a "Group (repeating)" in the fields list, add two fields there:

    ThisFieldNameSelected (true/false)
    ThisFieldNameText (text)

    and then we put this group on a form as a repeating table and add Default Values through the Tools -> Default Values dialog to pre-populate the available choices. The repeating table itself is set to not allow user to add or delete rows.

    And everything works really good until the form is updated with the new multi-select field.

    The issue I'm fighting with for a few days already is that when the template is updated with the new multi-select field (new field is added as described above), the newly created items are Ok. But the older ones, after being updated, display and store only the FIRST of the default values, defined for the newly created multi-select field in every repeated field. Old multi-valued fields, however, remain accurate.

    Let me give you an example:

    Initial template:

    Some field:

    [ ] Value ONE
    [ ] Value TWO
    [ ] Value THREE

    We publish that template on a sharepoint and start gathering the survey results. Everything works fine until the template v2 is not coming into the play.

    Updated template:

    Some field:

    [ ] Value ONE
    [ ] Value TWO
    [ ] Value THREE

    NEW field:

    [ ] FIRST value
    [ ] SECOND value
    [ ] THIRD value
    [ ] FOURTH value
    [ ] FIFTH value

    After the new template is published, the following result is observed - for the newly created items everything works as intended - no problems at all. But for the results, those were created using the initial template - all fields are shown / stored correctly BUT the newly added one.

    For the repeating fields, added in the Updated tamplate, the following result is observed on the form (no matter is we do Re-link the old results in the SharePoint or just confirm the form update when opening it for the first time with the updated template):

    ...

    NEW field:

    [ ] FIRST value
    [ ] FIRST value
    [ ] FIRST value
    [ ] FIRST value
    [ ] FIRST value

    So, the first defined default value is repeated for the whole list. The very same results are stored in the XML file:

    new results:

    <my:NewField>
    <my:NewFieldSelected>false</my:NewFieldSelected>
    <my:NewFieldText>FIRST value</my:NewFieldText>
    </my:NewField>
    <my:NewField>
    <my:NewFieldSelected>false</my:NewFieldSelected>
    <my:NewFieldText>SECOND value</my:NewFieldText>
    </my:NewField>
    <my:NewField>
    <my:NewFieldSelected>false</my:NewFieldSelected>
    <my:NewFieldText>THIRD value</my:NewFieldText>
    </my:NewField>
    <my:NewField>
    <my:NewFieldSelected>false</my:NewFieldSelected>
    <my:NewFieldText>FOURTH value</my:NewFieldText>
    </my:NewField>
    <my:NewField>
    <my:NewFieldSelected>false</my:NewFieldSelected>
    <my:NewFieldText>FIFTH value</my:NewFieldText>
    </my:NewField>

    old results with updated template:

    <my:NewField>
    <my:NewFieldSelected>false</my:NewFieldSelected>
    <my:NewFieldText>FIRST value</my:NewFieldText>
    </my:NewField>
    <my:NewField>
    <my:NewFieldSelected>false</my:NewFieldSelected>
    <my:NewFieldText>FIRST value</my:NewFieldText>
    </my:NewField>
    <my:NewField>
    <my:NewFieldSelected>false</my:NewFieldSelected>
    <my:NewFieldText>FIRST value</my:NewFieldText>
    </my:NewField>
    <my:NewField>
    <my:NewFieldSelected>false</my:NewFieldSelected>
    <my:NewFieldText>FIRST value</my:NewFieldText>
    </my:NewField>
    <my:NewField>
    <my:NewFieldSelected>false</my:NewFieldSelected>
    <my:NewFieldText>FIRST value</my:NewFieldText>
    </my:NewField>

    It really looks like either InfoPath issue or SharePoint issue or the integration issue, but I can't find anything on that topic so I'm starting to think that we're doing something terribly wrong.

    So, I would appreciate any help on this matter, since we're in urge already, people are complaining and I can't find an elegant solution to fix this one (creating a mid-level parsing utility that will force-convert the existing XMLs to comply with the new template is definately not an elegant way =)))

    Thank you!
    -----------------------------------
    Angelspire
  • 01-06-2011 10:01 PM In reply to

    Re: New multi-valued repeating tables corrupted after the template update

    Hi Angelspire and sorry for the delay over the holidays,

    First of all, good to see that you are moving towards a data-driven form for your values. This is definitely the paradigm to follow for surveys. We have done numerous surveys in this fashion and even have a couple recent blog posts on two starter techniques for this:

    Look at the schema in the starter template attached to the first link above. You will see a Modules group node with a Module repeating group inside of it and a Question repeating group inside that. This Question group is similar to what you want for your sample form. It has QuestionText and AnswerText in it. Corresponds to your NewFieldText and NewFieldSelected.

    You can look at how we set the values but in your case, you have multiple possible answers and those answers are changing between versions. You need to make sure that the AnswerText, i.e. the value, is an ID that corresponds to the text. Don't use hard-coded text since that text could change (for example, if you publish the form in a different language). So your values will be 1, 2, 3, etc. and you will look up the Display Text to display it based on the ID. That's the first change you need to make. When you decide to add new values, you will add new IDs for them. You can also this technique to update the text for old values.

    In your case, you have the added complexity of Multi-select control. I don't think the multi-select control is a good choice here because of how InfoPath interacts with it to set the values. I recommend changing the control and using default data (see first lab above) to automatically fill in all values. Then, you can add a button next to it that looks like a checkbox. If they click the button, it sets NewFieldSelected to true (default is false) and changes the button into a checkbox. You can do this by wrapping each button in a separate section and hide-showing them based on the state. This is an approach that may work for you since you won't be maligned by the default selection logic of the multi-select control. In other words, you'll control when the values change and how they are mapped. Existing old forms will work fine because the value is displayed in a text field and the button will just show checked or not depend on the false/true value.

    However, the false-true approach that you are using (on account of the multi-select control) is not a best practice for two reasons:

    1. Doesn't use value IDs - I explained why this is bad above
    2. Requires filtering to extract true data

    You should change it to use IDs and to only include the values that are set (not the non-set false values). That way, the data will not require filtering when you have to use it downstream.

    This may seem like a lot of stuff to think about. Please consider hiring one of our MVPs for a couple hours of one-on-one training. We can help you create the form that you need and figure out how to migrate your existing data and you'll learn how to do it (and why) so that your next form is easier. Go to Qdabra.com's Support page for more info on how to hire us for some quick help.

    Yours truly,

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.