Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath - InfoPath Dev Sign in | Join | Help in Newbie Questions InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » Newbie Questions » Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Last post 06-11-2013 07:46 AM by Omegacron. 22 replies. Page 1 of 2 (23 items) 1 2 Next > Sort Posts: Oldest to newest Newest to oldest Previous Next 11-26-2008 10:01 PM kelogs1347 Joined on 11-26-2008 Posts 9 Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Reply Contact Good day! I'm ultimately new to InfoPath and Sharepoint. What I'd like to do is to retrieve date from a SharePoint list (i.e. Project Activities) and put it in a repeating table. I've used this tutorial http://www.bizsupportonline.net/infopath2007/copy-rows-from-sharepoint-list-to-main-data-source.htm. I was able to retrieve the data but it got the value of only the first row. I've modified parts of the code specifically the while part and While rows.MoveNext() Dim activity As String = rows.Current.SelectSingleNode( _ "@Activity_Title", NamespaceManager).Value Dim project As String = rows.Current.SelectSingleNode( _ "@Project", NamespaceManager).Value Dim owner As String = rows.Current.SelectSingleNode( _ "/dfs:myFields/dfs:dataFields/dfs:Project_Activities/@Person_Responsible", NamespaceManager).Value Dim dueDate As Date = rows.Current.SelectSingleNode( _ "/dfs:myFields/dfs:dataFields/dfs:Project_Activities/@End_Date", NamespaceManager).Value Dim percentComplete As Double = rows.Current.SelectSingleNode( _ "@__Complete", NamespaceManager).Value ' Add the item to the repeating table AddItem(activity, project, owner, dueDate, percentComplete)End While The column Person_Responsible is of person/group type and the End_Date is of date type. This is what I'm getting when I run the form. It shows the same date and person responsible although from the list it's different.Please advice. Thanks in advance. Jess 11-26-2008 10:40 PM In reply to chandrakanth Joined on 06-25-2008 Posts 88 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact Hi, Please replace your while loop with this. While rows.MoveNext() Dim activity As String = rows.Current.SelectSingleNode( _ "@Activity_Title", NamespaceManager).Value Dim project As String = rows.Current.SelectSingleNode( _ "@Project", NamespaceManager).Value Dim owner As String = rows.Current.SelectSingleNode( _ "@Person_Responsible", NamespaceManager).Value Dim dueDate As Date = rows.Current.SelectSingleNode( _ "@End_Date", NamespaceManager).Value Dim percentComplete As Double = rows.Current.SelectSingleNode( _ "@__Complete", NamespaceManager).Value ' Add the item to the repeating table AddItem(activity, project, owner, dueDate, percentComplete)End While If the above code did not solve your problem.Please give the AddItem function code. Chandrakanth/GGKTech 11-26-2008 11:09 PM In reply to kelogs1347 Joined on 11-26-2008 Posts 9 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact I tried that and got this error Here's the AddItem function Private Sub AddItem( _ByVal activity As String, ByVal project As String, ByVal owner As String, ByVal dueDate As Date, ByVal percentComplete As Double) Dim doc As XmlDocument = New XmlDocument() Dim group As XmlNode = doc.CreateElement("activityItem", _ NamespaceManager.LookupNamespace("my")) Dim field As XmlNode = doc.CreateElement("activityName", _ NamespaceManager.LookupNamespace("my")) Dim node As XmlNode = group.AppendChild(field) node.InnerText = activity field = doc.CreateElement("project", _ NamespaceManager.LookupNamespace("my")) node = group.AppendChild(field) node.InnerText = project field = doc.CreateElement("activityOwner", _ NamespaceManager.LookupNamespace("my")) node = group.AppendChild(field) node.InnerText = owner field = doc.CreateElement("activityDueDate", _ NamespaceManager.LookupNamespace("my")) node = group.AppendChild(field) node.InnerText = dueDate.ToString("yyyy-MM-dd") field = doc.CreateElement("activityStatus", _ NamespaceManager.LookupNamespace("my")) node = group.AppendChild(field) node.InnerText = percentComplete doc.AppendChild(group) MainDataSource.CreateNavigator().SelectSingleNode( _ "/my:statusReport/my:activityItems", _ NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator()) End Sub 11-26-2008 11:55 PM In reply to chandrakanth Joined on 06-25-2008 Posts 88 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact Hi, This error might be the wrong "Person_Responsible" ,"End_Date" Xpaths that we mention in the while loop code.Please replace "Person_Responsible" ,"End_Date" xpath's in while loop with the corresponding attribute names in secondary schema. Chandrakanth/GGKTech 11-27-2008 12:29 AM In reply to kelogs1347 Joined on 11-26-2008 Posts 9 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact Hello, I don't think I goth the wrong Xpaths. But here's a picture of what my secondary data source loooks likeI'm not really sure why I'm getting that error. 11-27-2008 01:42 AM In reply to swathip Joined on 10-30-2007 India Posts 487 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact Hi, Before getting the value of a node, verify that node is existing or not. Check rows.Current.SelectSingleNode( "@Person_Responsible", NamespaceManager) is null or not. If it is not null then go for rows.Current.SelectSingleNode( _ "@Person_Responsible", NamespaceManager).Value. Do the same thing for other fields also. Swathipwww.ggktech.com 11-27-2008 01:53 AM In reply to Jimmy Joined on 07-03-2008 Posts 2,595 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact It appears that you are using the debugger here. Could you tell us on which line of code the error is occurring? Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 11-27-2008 05:48 PM In reply to kelogs1347 Joined on 11-26-2008 Posts 9 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact It's in this line: Dim owner As String = rows.Current.SelectSingleNode( _ "@Person_Responsible", NamespaceManager).Value 11-27-2008 06:15 PM In reply to Jimmy Joined on 07-03-2008 Posts 2,595 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact Is it possible that a certain row might not have a Person_Responsible assigned? If so, you'll probably want to make sure that rows.Current.SelectSingleNode("@Person_Responsible", NamespaceManager) Is not null (or Nothing, my VB is a bit shaky), and assign an empty string to owner if it is. Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 11-27-2008 06:21 PM In reply to kelogs1347 Joined on 11-26-2008 Posts 9 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact That's what baffles me because I made sure from my list that the Person Responsible column has values. Oh well I guess I'll just have to find another way. :) 11-27-2008 06:26 PM In reply to Jimmy Joined on 07-03-2008 Posts 2,595 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact What you can do is put a breakpoint on that line, then do a quick watch on rows.Current, and look at its OuterXml. That should give you some idea of what it looks like and what may be missing. You might have to iterate a few times to find the offending row. Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 11-27-2008 06:34 PM In reply to kelogs1347 Joined on 11-26-2008 Posts 9 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact swathip:Hi, Before getting the value of a node, verify that node is existing or not. Check rows.Current.SelectSingleNode( "@Person_Responsible", NamespaceManager) is null or not. If it is not null then go for rows.Current.SelectSingleNode( _ "@Person_Responsible", NamespaceManager).Value. Do the same thing for other fields also. How do you check if it's null or not? Sorry I'm really new to this. Thanks. 11-27-2008 06:39 PM In reply to kelogs1347 Joined on 11-26-2008 Posts 9 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact Jimmy:What you can do is put a breakpoint on that line, then do a quick watch on rows.Current, and look at its OuterXml. That should give you some idea of what it looks like and what may be missing. You might have to iterate a few times to find the offending row. I will try to do that. Thanks. 11-27-2008 07:16 PM In reply to Jimmy Joined on 07-03-2008 Posts 2,595 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact kelogs1347: swathip: Hi, Before getting the value of a node, verify that node is existing or not. Check rows.Current.SelectSingleNode( "@Person_Responsible", NamespaceManager) is null or not. If it is not null then go for rows.Current.SelectSingleNode( _ "@Person_Responsible", NamespaceManager).Value. Do the same thing for other fields also. How do you check if it's null or not? Sorry I'm really new to this. Thanks. It would be something like this: Dim tempNode As XPathNavigator = rows.Current.SelectSingleNode("@Person_Responsible", NamespaceManager)Dim owner As StringIf tempNode Is Nothing Then owner = "" Else owner = tempNode.Value Of course, if @Person_Responsible is always supposed to have a value it would be best to figure out what's going wrong. Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 11-27-2008 08:00 PM In reply to kelogs1347 Joined on 11-26-2008 Posts 9 Re: Retrieving Column Data from Sharepoint List to a Repeating Table in Infopath Mark as Not AnswerMark as Answer... Reply Contact I was able to figure out how to check if it was null and guess what it is. I don't really know why... Ok rant over..Sorry for that. :) Page 1 of 2 (23 items) 1 2 Next > Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Good day!
I'm ultimately new to InfoPath and Sharepoint. What I'd like to do is to retrieve date from a SharePoint list (i.e. Project Activities) and put it in a repeating table. I've used this tutorial http://www.bizsupportonline.net/infopath2007/copy-rows-from-sharepoint-list-to-main-data-source.htm. I was able to retrieve the data but it got the value of only the first row. I've modified parts of the code specifically the while part and
While rows.MoveNext() Dim activity As String = rows.Current.SelectSingleNode( _ "@Activity_Title", NamespaceManager).Value Dim project As String = rows.Current.SelectSingleNode( _ "@Project", NamespaceManager).Value Dim owner As String = rows.Current.SelectSingleNode( _ "/dfs:myFields/dfs:dataFields/dfs:Project_Activities/@Person_Responsible", NamespaceManager).Value Dim dueDate As Date = rows.Current.SelectSingleNode( _ "/dfs:myFields/dfs:dataFields/dfs:Project_Activities/@End_Date", NamespaceManager).Value Dim percentComplete As Double = rows.Current.SelectSingleNode( _ "@__Complete", NamespaceManager).Value ' Add the item to the repeating table AddItem(activity, project, owner, dueDate, percentComplete)End While
The column Person_Responsible is of person/group type and the End_Date is of date type. This is what I'm getting when I run the form.
It shows the same date and person responsible although from the list it's different.
Please advice. Thanks in advance.
Jess
Hi,
Please replace your while loop with this.
While rows.MoveNext() Dim activity As String = rows.Current.SelectSingleNode( _ "@Activity_Title", NamespaceManager).Value Dim project As String = rows.Current.SelectSingleNode( _ "@Project", NamespaceManager).Value Dim owner As String = rows.Current.SelectSingleNode( _ "@Person_Responsible", NamespaceManager).Value Dim dueDate As Date = rows.Current.SelectSingleNode( _ "@End_Date", NamespaceManager).Value Dim percentComplete As Double = rows.Current.SelectSingleNode( _ "@__Complete", NamespaceManager).Value ' Add the item to the repeating table AddItem(activity, project, owner, dueDate, percentComplete)End While
If the above code did not solve your problem.Please give the AddItem function code.
I tried that and got this error
Here's the AddItem function
Private Sub AddItem( _ByVal activity As String, ByVal project As String, ByVal owner As String, ByVal dueDate As Date, ByVal percentComplete As Double) Dim doc As XmlDocument = New XmlDocument() Dim group As XmlNode = doc.CreateElement("activityItem", _ NamespaceManager.LookupNamespace("my")) Dim field As XmlNode = doc.CreateElement("activityName", _ NamespaceManager.LookupNamespace("my")) Dim node As XmlNode = group.AppendChild(field) node.InnerText = activity field = doc.CreateElement("project", _ NamespaceManager.LookupNamespace("my")) node = group.AppendChild(field) node.InnerText = project field = doc.CreateElement("activityOwner", _ NamespaceManager.LookupNamespace("my")) node = group.AppendChild(field) node.InnerText = owner field = doc.CreateElement("activityDueDate", _ NamespaceManager.LookupNamespace("my")) node = group.AppendChild(field) node.InnerText = dueDate.ToString("yyyy-MM-dd") field = doc.CreateElement("activityStatus", _ NamespaceManager.LookupNamespace("my")) node = group.AppendChild(field) node.InnerText = percentComplete doc.AppendChild(group) MainDataSource.CreateNavigator().SelectSingleNode( _ "/my:statusReport/my:activityItems", _ NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator())
End Sub
This error might be the wrong "Person_Responsible" ,"End_Date" Xpaths that we mention in the while loop code.Please replace "Person_Responsible" ,"End_Date" xpath's in while loop with the corresponding attribute names in secondary schema.
Hello,
I don't think I goth the wrong Xpaths. But here's a picture of what my secondary data source loooks like
I'm not really sure why I'm getting that error.
Before getting the value of a node, verify that node is existing or not. Check rows.Current.SelectSingleNode( "@Person_Responsible", NamespaceManager) is null or not. If it is not null then go for rows.Current.SelectSingleNode( _ "@Person_Responsible", NamespaceManager).Value.
Do the same thing for other fields also.
It appears that you are using the debugger here. Could you tell us on which line of code the error is occurring?
It's in this line: Dim owner As String = rows.Current.SelectSingleNode( _ "@Person_Responsible", NamespaceManager).Value
Is it possible that a certain row might not have a Person_Responsible assigned? If so, you'll probably want to make sure that
rows.Current.SelectSingleNode("@Person_Responsible", NamespaceManager)
Is not null (or Nothing, my VB is a bit shaky), and assign an empty string to owner if it is.
That's what baffles me because I made sure from my list that the Person Responsible column has values. Oh well I guess I'll just have to find another way. :)
What you can do is put a breakpoint on that line, then do a quick watch on rows.Current, and look at its OuterXml. That should give you some idea of what it looks like and what may be missing.
You might have to iterate a few times to find the offending row.
swathip:Hi, Before getting the value of a node, verify that node is existing or not. Check rows.Current.SelectSingleNode( "@Person_Responsible", NamespaceManager) is null or not. If it is not null then go for rows.Current.SelectSingleNode( _ "@Person_Responsible", NamespaceManager).Value. Do the same thing for other fields also.
How do you check if it's null or not? Sorry I'm really new to this. Thanks.
Jimmy:What you can do is put a breakpoint on that line, then do a quick watch on rows.Current, and look at its OuterXml. That should give you some idea of what it looks like and what may be missing. You might have to iterate a few times to find the offending row.
I will try to do that. Thanks.
kelogs1347: swathip: Hi, Before getting the value of a node, verify that node is existing or not. Check rows.Current.SelectSingleNode( "@Person_Responsible", NamespaceManager) is null or not. If it is not null then go for rows.Current.SelectSingleNode( _ "@Person_Responsible", NamespaceManager).Value. Do the same thing for other fields also. How do you check if it's null or not? Sorry I'm really new to this. Thanks.
swathip: Hi, Before getting the value of a node, verify that node is existing or not. Check rows.Current.SelectSingleNode( "@Person_Responsible", NamespaceManager) is null or not. If it is not null then go for rows.Current.SelectSingleNode( _ "@Person_Responsible", NamespaceManager).Value. Do the same thing for other fields also.
It would be something like this:
Dim tempNode As XPathNavigator = rows.Current.SelectSingleNode("@Person_Responsible", NamespaceManager)Dim owner As StringIf tempNode Is Nothing Then owner = "" Else owner = tempNode.Value
Of course, if @Person_Responsible is always supposed to have a value it would be best to figure out what's going wrong.
I was able to figure out how to check if it was null and guess what it is. I don't really know why...
Ok rant over..Sorry for that. :)