Populating repeating table from a Sharepoint list using C# - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Populating repeating table from a Sharepoint list using C#

Last post 11-21-2018 12:34 AM by ajiichiban. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 11-12-2018 12:30 AM

    Populating repeating table from a Sharepoint list using C#

    I'm new to repeating tables and C# so I'm hoping I can get some guidance

    I am designing a form which reads items from a SP custom list called TestCustomList. This form needs to associate all the items in the list with an ID generated by the form (forming a many to one relationship). This is just a test prototype, the actual form will need to populate other fields besides the ID.

    The way I plan to go about this is to create a repeating table and bind it to TestCustomList directly and hide it within a section. I will create another (local) repeating table and use C# code to copy from the SP bound rpt table to the local one.
    http://www.bizsupportonline.net/infopath2007/copy-rows-from-sharepoint-list-to-main-data-source.htm

    I plan to use this in conjuction with C# code which will allow me to submit a repeating table to a list:
    http://www.bizsupportonline.net/infopath2007/how-to-submit-items-rows-repeating-table-infopath-sharepoint-list.htm

    I have uploaded the C# code that I am using. I needed to write something to the other fields in the repeating table otherwise when I load the form, the fields that I don't modify, become read-only in the form. So in the screenshot, I only write to field1, field2 and field5 have been commented out. When I load the form field2 and field5 are read only. If i uncomment the code, when I load the form these fields are writable. Do I need to write a blank character to every field I don't want to populate or is there a better way?

    Also, if I use C# to populate a field in the repeating table, will that prevent the trigger of a rule to set the field in the second column of the repeating table? Currently the rule is not populating the second column in the repeating table when the form loads. After I uncomment the lines as described above, the form still does not auto populate field2. However if I trigger a changed event on field1, field2 is populated via the rule.

    Rule XPath: xdXDocument:GetDOM("TestCustomList")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ID[../d:Title = current()]

    Thanks

    Filed under: ,
  • 11-13-2018 02:40 PM In reply to

    Re: Populating repeating table from a Sharepoint list using C#

    So - it isn't that the fields are read only - it is that they don't exist at all. :) You can just continue using this approach and leave them blank. I usually get a node from the sample data and clone it instead, because that way all the fields are there. As to the rule on field1 running - I think it won't run since the field is populated via code. Could you just also populate field2 as desired in your code?
    Hilary Stoupa

  • 11-14-2018 01:12 AM In reply to

    Re: Populating repeating table from a Sharepoint list using C#

    Thanks Hilary

    That makes sense

    I can populate field2 using code, just wanted to confirm that the C# code won't trigger rules

    Just realised that this is sandboxed code and may be an issue on SharePoint Online. I'll investigate if a codeless solution is feasible. The posts look like they may work if I can combine the two

    Copy repeating data
    http://www.infopathdev.com/blogs/patrick/archive/2011/09/03/free-sample-copying-repeating-data.aspx

    Codeless submit to sharepoint list
    http://www.infopathdev.com/forums/t/26246.aspx?PageIndex=1

  • 11-14-2018 07:18 AM In reply to

    Re: Populating repeating table from a Sharepoint list using C#

    You won't be able to use code in a browser form on SharePoint Online, sandbox has been deprecated... so yah, you are going to have to take a codeless approach.
    Hilary Stoupa

  • 11-20-2018 01:19 AM In reply to

    Re: Populating repeating table from a Sharepoint list using C#

    I've got the form submitting to the sharepoint online list with the web submit on Infopath.

    However when I upload the form to a SPO document library, and run it via the browser, I get numerous errors:
    An error occurred while trying to connect to a Web service.

    Should this still work on SPO?

  • 11-20-2018 11:45 AM In reply to

    Re: Populating repeating table from a Sharepoint list using C#

    I missed where you said you were going to try to submit to a list - many SharePoint web services aren't available in browser forms on SharePoint Online, unfortunately.
    Hilary Stoupa

  • 11-21-2018 12:34 AM In reply to

    Re: Populating repeating table from a Sharepoint list using C#

    Ah i see. Thanks for confirming Hilary. I suspected this was going to be the case
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.