Updating SharePoint list from Repeating Table (multiple records) - InfoPath Dev
in

InfoPath Dev

Updating SharePoint list from Repeating Table (multiple records)

Last post 12-05-2010 03:38 PM by infodude2010. 16 replies.
Page 1 of 2 (17 items) 1 2 Next >
Sort Posts: Previous Next
  • 11-25-2010 04:33 PM

    Updating SharePoint list from Repeating Table (multiple records)

    Application design:

    1. Select student
    2. Get student's tasks from SharePoint List
    3. Mark student's tasks
    4. Save the changes back to the SharePoint list.


    All student tasks are stored in a SharePoint list.

    I.e.

    SharePoint list fields:

    Student
    Task Desc
    Task Due Date
    Mark
    Mark Date
    Comments


    I'm using a drop-down list to select a student first, and it populates a repeating table with student tasks from the SharePoint list. I use a data source that just gets everything from the sharePoint list and I use the drop-down at the top of the page to filter it based on student's name. 

    Only "Mark" and "Comments" fields should be edited on the form. "Mark Date" should be populated automatically when the mark is given.

    How do I submit this repeating table's values back to my SharePoint list where the marks are stored?

    Can it even be done? Can I edit and submit changes for more than 1 record at a time?

     

    Thank you.

  • 11-29-2010 03:10 PM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    Hey there -- qRules can do this for you (and more). Even better, you can download a free trial to give it a whirl. The current trial expires 12/15/2010, but if that doesn't provide you with adequate time give it a try, you can email me through the forum and I can get you squared away with an extension.

    What you'd need from qRules is the FilterOwssvr command to return just the list items for the selected student (or, you could continue returning all records and filtering, but if your list may get big, it would be better to return only the data you need -- if you are using ShP 2010, I think you have query fields for list queries now, as well).

    Then you could use the CopyTable command (or Jo-Anne's cool work around) to copy the data into your main data source. From there, SubmitToSharePoint list command to update your list items.

    Of course, your other options would be to use CAML to update a single item at a time (there are samples of this online and on this site) or to write a big mess of custom code. Neither of those will have the re-usability of qRules, and, of course, solve only your current problem instead of helping you with future InfoPath challenges...

    Hilary Stoupa

  • 11-29-2010 08:56 PM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    Q-rules is a nice product to give it a try, but if you are not interested to invest money on this requirement, you can do this by using VSTA code. I assume you are good at it, just create an instance of your repeating table node as xpathnodeierator and then you can access individual rows by using instance.movenext. make sure to create an instance of xpathnavigator as, iteratiorinstance.current.createnavigator(), let me know if you find some problem. I have done this several tie and can pass yoy my code for it.

     I would also like to advice you one thing, Infopath is a great tool provided by Microsoft, you just need to explore the possiblities and u'll realize it can do anything with less amount of coding. Have  a great day.

    Vishal Srivastava
    Senior Software Engineer
    SDG Software Pvt Ltd
  • 11-30-2010 08:22 AM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    Thanks Vishal for the great post! :)

    Patrick Halstead
    Project Manager at Qdabra
  • 11-30-2010 09:46 PM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    Hey Vishal,

     Thanks for your suggestion. I'll definitly try this one out, althouth I was hoping to avoid any coding this time around :)

     If you could shoot me your sample code I'd really appreciate it.

     Thanks,

    Alex.

  • 11-30-2010 09:47 PM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    Thanks, Hillary. I have already downloaded qRules, but havent been able to work out a way of submitting multiple updates back to the source list from my form.

  • 11-30-2010 10:25 PM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    Not a full code but enough to give you an idea

    XPathNodeIterator xnav = MainDataSource.CreateNavigator().Select("/my:IdeaBankFields/my:IdeaBankGrp/my:IdeaBank", NamespaceManager);

     

    while (xnav.MoveNext())

    {

    XPathNavigator ideaNav = xnav.Current.CreateNavigator();

    string postTitle = ideaNav.SelectSingleNode("my:IdeaTitle", NamespaceManager).Value;

    string userName = ideaNav.SelectSingleNode("my:Createdby", NamespaceManager).Value;

    string Currentuser = ideaNav.SelectSingleNode("my:UserDisplayName", NamespaceManager).Value;

    if (Currentuser == userName)

    {

    ideaNav.SelectSingleNode(
    "my:DisableVote", NamespaceManager).SetValue("1");

    }

    SPSecurity.RunWithElevatedPrivileges(delegate()

    {

    using (SPSite rootsite = new SPSite("http://vm-sp-vishal:1001"))

    {

    using (SPWeb rootweb = rootsite.OpenWeb("pepsiBlogs"))

    {

    SPList Votelist = rootweb.Lists["PostsVote"];

    SPListItemCollection itemColl = Votelist.Items;

    SPQuery query = new SPQuery();

    //Build query

    query.Query = "<Where><Eq><FieldRef Name='PostTitle'/><Value Type='Text'>" + postTitle + "</Value></Eq></Where>";

    SPListItemCollection collection = Votelist.GetItems(query);

    if (collection.Count > 0)

    {

    SPListItem item = collection[0];

    string[] VotedUsernames = SplitUsernames(item["Usernames"].ToString());

    for (int i = 0; i < VotedUsernames.Length; i++)

    {

    if (VotedUsernames[i] == Currentuser)

    {

    ideaNav.SelectSingleNode(
    "my:DisableVote", NamespaceManager).SetValue("1");

    }

    }

    }

    }

    }

    });

    }

    Vishal Srivastava
    Senior Software Engineer
    SDG Software Pvt Ltd
  • 12-01-2010 08:35 AM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    Hmmm. It would help me help you with qRules if I knew what you had tried. :)

    As I mentioned, you'll need to copy the source list into your main data source -- using CopyTable if the schemas match or the work around I linked to in my first post if they do not. After you have your secondary data in your main data source, then you'll be able to use SubmitToSharePointList to update your items -- you need to be sure that you have copied in your list item id, as well.

     Let me know where you are stuck, and I'll be happy to help you out!

    Hilary Stoupa

  • 12-01-2010 03:56 PM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    I'm not sure what you mean by "main data source" and "secondary data".

    I have one list where my input data is stored and I need to use this data to populate my form. Once the form is populated I need to be able to update multiple items in one go and save these into my Forms library (which will obviously need to have a different schema than my input list). The challenge is to display only relevant items on the form and then save these into my form library.

    I had a look at the CopyTable example but I'm not sure it's suitable (or maybe I'm just missing something due to my inexperience with InfoPath).

     

  • 12-01-2010 04:55 PM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    The list where your input data is stored is a secondary data source, I'd guess. Did you add a data connection to the list in order to get the data into your form?

    When you say you need to "to update multiple items in one go and save these into my Forms library" I get confused. I know you are talking about SharePoint list items -- when you talk about a Library, do you mean a Form Library where you will save the completed XML?

    To me, it sounds like you might want to do this:

    Open your form. Select a student. Copy the student's tasks into the form (this would be the main data source -- only data in the main data source is saved when we save the XML created with a template). Allow the user to make some edits. Update the tasks in the original SharePoint list. Save the form (XML) to a library with the tasks and the edits. CopyTable could be used to copy the student tasks into the form (either by using an XPath filter or by using an owssvr data source and utilizing the FilterOwssvr command)

    Or, perhaps you want to:

    Open your form. Select a student. Make changes to the student's tasks from the form and save those changes back to the list, without saving anything from your form. Your original post suggests this is what you'd like to do -- and I have to say, if this is all that is desired, wouldn't data sheet view in the list with a filter take care of this without needing any other layers?

    Hilary Stoupa

  • 12-01-2010 06:42 PM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    Thanks for this clarification.

    1 student has multiple tasks assigned to him/her. I will pre-create individual forms for each student, and provide a direct link to each student so they can only update their own tasks. That's my main requirement - being able to pre-create these forms and have students being able to update only their tasks on their form. Hence Datasheet view is not suitable.

     Here is what my input data list looks like:

    Here is what my forms looks like (using repeating table and a conditional formating rule to filter unwanted items):

    I want the student to be able to tick-off multiple tasks at once, and provide comments on relevant tasks. Upon submition the data will be saved to the SharePoint Forms library where the form lives.

    I used repeating table to demontrate what I'm trying to get to.

    Does this make it clearer?

  • 12-01-2010 07:18 PM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    This is a common scenario. We have done very similar SharePoint list data into InfoPath form many times. You'll want to read Jo-Anne's blog which describes a data driven technique using the qRules Insert command to iteratively copy tasks from SharePoint into your form. Another approach would be to simply query the SharePoint list for the Task data using qRules FilterOwssvr command which may give you exactly what you want with much less configuration. Then, you'll use qRules SubmitToSharePointList to update the values when the student clicks submit. As an extra bonus, you can also check to make sure there wasn't an intervening update by someone else and show conditional warning in the view if that is the case. You could even highlight which items changed. Hilary has a blog post on doing this delta calculation to track changes in list items between edits since unlike InfoPath XML forms there's no way to lock a list row during edit.

    This brings up another solution - use a form library instead of a list and a separate XML (instead of a list row) for each task. Then, your form becomes a "container" form that queries other XML using qRules FilterOwssvr to pull down only those tasks that are a) active and b) assigned to the current student. The benefit of doing this is you have to do less "diff tracking" between edits since each XML can be locked when it is loaded into the form (Hilary has a more recent blog post on how to use CheckIn and CheckOut to do that).

    Any way you go, I'm guessing an hour or two to get this working. If you purchase qRules, you'll get an hour of free support. :)

    Patrick Halstead
    Project Manager at Qdabra
  • 12-01-2010 07:26 PM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    Patrick,

    Thank for your suggestions.I guess I don't have to keep the tasks and their completion details in one (input) list - i.e. the input can contain just the task desc, student name and due date, and my form will copy this and add completion details.

    I'm happy to purchase qRules if it saves me time. I'll try to figure it out using a trial version which I have already downloaded.

    Cheers,

    Alex.

  • 12-01-2010 09:42 PM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)


    Can't get Jo-Anne's example to work :(((( Besides I think it's not going to work for web-based forms anyway.

    I'm at a point where I think to give up on using InfoPath for this, cause it seems too hard.

  • 12-01-2010 10:32 PM In reply to

    Re: Updating SharePoint list from Repeating Table (multiple records)

    Well, it's not tough just tricky. Now coming to possibility of doing this, it's not just possible but simple as well you just need concentration and dedication to make it possible. Well, if your scenario is to get the students tasks , students name and some other data from a list hosted in sharepoint and then send those tasks to students individually,. I m busy my work right now otherwise it is just an hour or two hour job job, if you can wait till sunday, i will send you the working form with detailed instructions on how to use that form. Send me your mail id if you are OK with it.

    Vishal Srivastava
    Senior Software Engineer
    SDG Software Pvt Ltd
Page 1 of 2 (17 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.