How can I write values in special rows of a repeating table? - InfoPath Dev
in

InfoPath Dev

Now you can find InfoPathDev on YouTube and Twitter!

How can I write values in special rows of a repeating table?

Last post 11-10-2009 12:41 PM by Reztips. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 10-10-2008 06:45 AM

    How can I write values in special rows of a repeating table?

    Hello,

    I want to use a WebService to write data in a special Sharepoint column. Therefore I have an XML-File as secondary datasource which is implemented in the form as repeating table (similar to this description: http://blogs.msdn.com/infopath/archive/2007/03/26/submitting-to-a-sharepoint-list.aspx)

    But now the problem: I want to write content into the repeating table. The values are already in the form -> two text fields (field1/field2). But I can`t find any way to tell InfoPath: Write the content of field 1 to row 1 and field 2 to row 2

    It would be nice, if anybody could provide a codeless solution for this problem!

    Can give a xPath to field1 in the XML-Container? if yes => how?  Or is there any way to filter the target field in the rule "set a field`s value"?

  • 10-24-2008 07:56 AM In reply to

    Re: How can I write values in special rows of a repeating table?

     If I understand your question correctly, then there is a way to do this without code, but I think you will need to get involved with the form's source just a little bit.

    I have a form with two text fields, field1 and field2, and a single-column repeating table bound to /my:myFields/my:group1/my:group2(repeating). The column's nodes are bound to my:group2/my:field3

    I add a button and give it two rules:

    Set my:field3 to value of my:field1
    Set my:field3 to value of my:field2

    I preview the form, add several rows to the repeating table, enter values for field1 and field2 and click the button. All rows of the table are filled with the value of field2.  This is obviously not what we want, as I'm sure you've guessed.

    I now go back to design mode, and select Save as Source Files... from the File menu and choose a folder for their destination.  I close InfoPath.

    I browse to the folder and open the manifest.xsf file in an XML editor (a text editor would also work).

    I search for the text "ruleset" until I find a section of text that looks like this:

    <xsf:ruleSets>
         <
    xsf:ruleSet name="ruleSet_1">
              <
    xsf:rule caption="Rule 1" isEnabled="yes">
                   <
    xsf:assignmentAction targetField="my:group1/my:group2/my:field3" expression="my:field1"></xsf:assignmentAction>
              </
    xsf:rule>
              <
    xsf:rule caption="Rule 2" isEnabled="yes">
                   <
    xsf:assignmentAction targetField="my:group1/my:group2/my:field3" expression="my:field2"></xsf:assignmentAction>
              </
    xsf:rule>
         </
    xsf:ruleSet>
    </
    xsf:ruleSets>

    The salient parts are the <xsf:assignmentAction> nodes.  They are telling the form to copy field1 and field2 into my:group1/my:group2/my:field3 whenever these rules are carried out.  Now I add subscripts after my:group2 in the targetField attributes to specify specific rows, like this:

    <xsf:ruleSets>
         <
    xsf:ruleSet name="ruleSet_1">
              <
    xsf:rule caption="Rule 1" isEnabled="yes">
                   <
    xsf:assignmentAction targetField="my:group1/my:group2[1]/my:field3" expression="my:field1"></xsf:assignmentAction>
              </
    xsf:rule>
              <
    xsf:rule caption="Rule 2" isEnabled="yes">
                   <
    xsf:assignmentAction targetField="my:group1/my:group2[2]/my:field3" expression="my:field2"></xsf:assignmentAction>
              </
    xsf:rule>
         </
    xsf:ruleSet>
    </
    xsf:ruleSets>

    Now I save and close the manifest, right click the file, choose Design, and preview the form.  I repeat the steps I performed during the last preview, and this time only the first two rows are populated. I close the preview and choose File->Save As... to re-save the form as an .xsn file.

    Jimmy Rishe / Software Developer
    Qdabra Software
  • 10-27-2008 03:13 AM In reply to

    Re: How can I write values in special rows of a repeating table?

    Hi Jimmy,

    that`s exactly I was looking for! It works very well. Thank you!

  • 05-07-2009 12:55 PM In reply to

    Re: How can I write values in special rows of a repeating table?

    This is great.  If I wanted to do this repeatedly, could I use an integer text field, for example my:index, that is increased when a button is clicked?

  • 11-10-2009 12:41 PM In reply to

    Re: How can I write values in special rows of a repeating table?

    Hi Jimmy...just reading this post....a year later.  :)

    Your solution seems to work for infopath forms.  However, I get the following error in the browser compatability section since I am developing a web-based form:

     "The following expression could not be parsed because of a syntax error or because it uses and undefined namespace prefix or unsupported function: xdXDocument:GetDOM("AuditList")/Batch/Method/Field[1]

    Here is the entire XML entry: 

    <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;AuditList&quot;)/Batch/Method/Field[1]" expression="xdDate:Now()"></xsf:assignmentAction>

     I have also Tried this:

    <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;AuditList&quot;)/Batch[1]/Method/Field" expression="xdDate:Now()"></xsf:assignmentAction>

     I have also Tried this:

    <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;AuditList&quot;)/Batch/Method[1]/Field" expression="xdDate:Now()"></xsf:assignmentAction>

    "AuditList" is an XML file depicting a SharePoint List.

     Is there a web-based soluton for this?

     

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