none
Help on infopath meeting form

    Question

  • I have a requirement wherein I will be creating an infopath form.

    This infopath form will retrieve the list of tasks from a task list. the tasks that will be retrieve are the all tasks with Pending status from the previous meeting and all tasks for the current meeting. I only have one task list so I need to query it. This is my problem, how will I query it, what flags should I put in order to query it correctly. I decided to post it here coz I am having trouble thinking of the logic.

    Let me know if you need more info

    Thanks


    ----------------------- Sharepoint Newbie

    Monday, September 23, 2013 1:38 AM

Answers

  • Ok understood. Don't drag and drop connection on form because it won't allow you edit rows. You need to populate table via code. Follow below steps:

    1. Create  a list data connection:

    2. Add a repeating table in form

    3. Use below code to populate this table on page load (write code on page load and change Xpath URL based on your controls)

    XPathNavigator rTable = MainDataSource.CreateNavigator();
    XPathNodeIterator tableRowsA = rTable.Select("/my:myFields/my:ProfileAccess_section/my:AccessProfileA/my:AccessProfileAA", NamespaceManager);//repeating table
    if (tableRowsA.Count > 0)
    {
     for (int i = tableRowsA.Count; i > 0; i--)
    {
     XPathNavigator reTableRows = rTable.SelectSingleNode("/my:myFields/my:ProfileAccess_section/my:AccessProfileA/my:AccessProfileAA[" + i + "]", NamespaceManager);
                                reTableRows.DeleteSelf();
     }
    }
    //Connect to secondary list data source
    DataSource ds = DataSources["GetData"];
    XPathNavigator domNav = ds.CreateNavigator();
    XPathNodeIterator rows = domNav.Select("/dfs:myFields/dfs:dataFields/tns:GetDataResponse/tns:GetData/NewDataSet/DynamicData", NamespaceManager);
    
    
     while (rows.MoveNext())
                        {
    using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:ProfileAccess_section/my:AccessProfileA", NamespaceManager).AppendChild())
    {
                                    writer.WriteStartElement("AccessProfileAA", myNamespace);
                                    writer.WriteElementString("rdb_AccessProfileA", myNamespace, Action);
                                    writer.WriteEndElement();
    writer.Close();
    }}

    http://stevemannspath.blogspot.in/2010/09/infopath-20072010-populate-repeating.html

    4. Now on submit button, add code to update item in list, which you already have.

    Let me know if still face any issue


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, September 23, 2013 9:21 AM
    Moderator

All replies

  • How will I retrieve/populate my repeating table with values from my sharepoint list without using web services?

    ill be doing this in the loading event of my infopath. thanks


    ----------------------- Sharepoint Newbie

    Monday, September 23, 2013 6:36 AM
  • Hello,

    You don't need to call web service here if just need to get data from SP list. you can create direct connection to list and add that Dc to form as repeating table.(No code or service is required here)

    http://www.bizsupportonline.net/blog/2011/01/2-ways-use-repeating-table-sharepoint-list-infopath-2010/

    Now if you need to filter the table records then create conditional rules to hide/show rows:

    http://office.microsoft.com/en-in/infopath-help/show-or-hide-rows-in-a-repeating-table-by-using-conditional-formatting-HA010033885.aspx

    Let us know in case any doubt


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, September 23, 2013 7:16 AM
    Moderator
  • Okay here's an additional detail on what I will be doing on my loading event,

    I have a task list which is tagged with IDs (ID=1,2,3,4 etc, -- actually these are like batches for meetings like meeting 1, 2 3 etc)

    for example a user will now create an infopath form that will be using ID=4, so when the user opens the form, it will show all in progress task from the task list with ID=3.

    This post is related to my other post here in this forum.

    so the user can edit the existing tasks (under batch ID=3) and create new tasks (under batch ID=4). and will update the task list.

    is this possible?

    thanks.


    ----------------------- Sharepoint Newbie


    • Edited by 120613 Monday, September 23, 2013 7:38 AM
    Monday, September 23, 2013 7:36 AM
  • I have merged your both threads.

    >it will show all in progress task from the task list with ID=3.

    As i said in earlier post, you can hide/show control by creating conditional formatting rule. In your case you can add rule like: If ID =3 then hide control.

    Now if you want to update same task then you may use lists.asmx web service to update the item in list as suggested in below thread.

    http://social.technet.microsoft.com/Forums/en-US/1b2814e3-888c-4672-83c1-1bcabbdab34d/retrieve-items-from-sp-list-and-display-it-in-a-repeating-table-and-vice-versa

    OR

    You can also use object model code to update list item:

    http://www.bizsupportonline.net/browserforms/update-sharepoint-list-items-object-model-infopath-browser-form.htm

    Hope it could help


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, September 23, 2013 8:49 AM
    Moderator
  • Thanks.

    I have a question regarding your reply on my other thread:

    Create a data list data connection and display data in table by drag and drop the connection on page as repeating table.

    Will I be creating a data connection that retrieves the columns I need from my list? how will I drag and drop the connection to my design mode in infopath? Thanks.

    I already had the solution on how to save the repeating table contents to an SP List. now my only problem is the retrieval of the items.


    ----------------------- Sharepoint Newbie

    Monday, September 23, 2013 8:59 AM
  • Ok understood. Don't drag and drop connection on form because it won't allow you edit rows. You need to populate table via code. Follow below steps:

    1. Create  a list data connection:

    2. Add a repeating table in form

    3. Use below code to populate this table on page load (write code on page load and change Xpath URL based on your controls)

    XPathNavigator rTable = MainDataSource.CreateNavigator();
    XPathNodeIterator tableRowsA = rTable.Select("/my:myFields/my:ProfileAccess_section/my:AccessProfileA/my:AccessProfileAA", NamespaceManager);//repeating table
    if (tableRowsA.Count > 0)
    {
     for (int i = tableRowsA.Count; i > 0; i--)
    {
     XPathNavigator reTableRows = rTable.SelectSingleNode("/my:myFields/my:ProfileAccess_section/my:AccessProfileA/my:AccessProfileAA[" + i + "]", NamespaceManager);
                                reTableRows.DeleteSelf();
     }
    }
    //Connect to secondary list data source
    DataSource ds = DataSources["GetData"];
    XPathNavigator domNav = ds.CreateNavigator();
    XPathNodeIterator rows = domNav.Select("/dfs:myFields/dfs:dataFields/tns:GetDataResponse/tns:GetData/NewDataSet/DynamicData", NamespaceManager);
    
    
     while (rows.MoveNext())
                        {
    using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:ProfileAccess_section/my:AccessProfileA", NamespaceManager).AppendChild())
    {
                                    writer.WriteStartElement("AccessProfileAA", myNamespace);
                                    writer.WriteElementString("rdb_AccessProfileA", myNamespace, Action);
                                    writer.WriteEndElement();
    writer.Close();
    }}

    http://stevemannspath.blogspot.in/2010/09/infopath-20072010-populate-repeating.html

    4. Now on submit button, add code to update item in list, which you already have.

    Let me know if still face any issue


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, September 23, 2013 9:21 AM
    Moderator
  • Thanks for the help. I was able to display the contents of the task list to my repeating table.

    Ill let you know if I have other questions. can we just leave this thread unanswered thanks

    • Edited by 120613 Tuesday, September 24, 2013 7:35 AM
    Monday, September 23, 2013 11:53 PM
  • >What are these XPaths?

    See my form schema and change with your:

    Just try with simple controls like textbox, checkbox etc then use person picker. I suspect there is problem with picker control. So i would suggest first do with simple controls and understand the  code then do it with picker.


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, September 24, 2013 6:19 AM
    Moderator
  • yes I finally got the solution for the picker  control by using "pc" as lookupNamespace.

    Ill let you know if I have any other questions/help thanks


    ----------------------- Sharepoint Newbie

    Tuesday, September 24, 2013 7:38 AM
  • Ive got another question.

    Since I have another field in my repeating table where the SPListeItem ID is stored during the loading event.

    and when I inserted a new item in my repeating table, that ID is blank right? and what I want to do is I want to retrieve the SPListItem ID after saving and save it in that particular control.

    My question is how should I do that? will I need to perform XmlWriter again? because I tried to set the value for the node "my:itemId" and it gives me an error. and if I use the full Xpath "/my:A/my:AI/my:RepeatingTable/my:ItemId" only the 1st node is updated.

    How will I address this?

    thanks


    ----------------------- Sharepoint Newbie


    • Edited by 120613 Wednesday, September 25, 2013 3:03 AM
    Wednesday, September 25, 2013 3:03 AM
  • I think you need to rebind the table after adding item in list. Since ID generates after adding item in list so try to rebind the table with same data connection after click on submit button.

    If still does not works then create a new DC on same list, add one one table in form and then bind data in new table with new connection.

    Just try this out and let me know your result


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, September 25, 2013 6:48 AM
    Moderator
  • Hi what I did is this.

    I created a method that returns int id that will, this method saves the SPListItem, i then retrieve the item id and then save it in a control.

    thanks.

    I have another question regarding loading event.

    1. I have a Status control, this is my checker if I will retrieve the list items on form load, if it is null, then I will change the value to New

    2. Then I have an if statement that if status == new, then I will retrieve the list items

    3. at the end of the if, i will set the value to something like Updated or something like that.

    4. My problem now is that when I verify a person in the people picker, the Form Loading event will be called again and when checking the value of the Status field, it is still again null, thus this will again retrieve the list items. It seems that in the UI, the value is now Updated but in debug mode, it is still null.

    How will I prevent this from happening?

    Also, how can I customize the NotifyHost? I want to perform custom code when NotifyHost OK button is clicked.


    ----------------------- Sharepoint Newbie


    • Edited by 120613 Thursday, September 26, 2013 3:23 AM
    Wednesday, September 25, 2013 11:17 PM
  • People picker is come with post back so you can't prevent it. You may try some tricky solution (don't know at this moment without seeing your code).

    >how can I customize the NotifyHost?

    You may try like this:

    http://msdn.microsoft.com/en-us/library/microsoft.office.infopath.server.controls.xmlformview.notifyhost.aspx


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, September 26, 2013 4:56 AM
    Moderator
  • Heres my code for the formevents_loading

    string formStatus = InfoPath.GetDomValue(MainDataSource, NamespaceManager, XPath.FORM_STATUS);
    
                if (formStatus == "NewForm")
                {
                    InfoPath.SetMainDomValue(MainDataSource, NamespaceManager, XPath.FORM_STATUS, "New");
                    formStatus = InfoPath.GetDomValue(MainDataSource, NamespaceManager, XPath.FORM_STATUS);
                }
    
                if (formStatus == "New")
                {
    //retrieve list items and display to repeating table
    }
    InfoPath.SetMainDomValue(MainDataSource, NamespaceManager, XPath.FORM_STATUS, "Modified");

    So whats happening here when im debugging is that the initial value of status is "NewForm"

    so it satisfies the if statement and sets the value to "New"

    it will proceed and satisfy the next if statement and will retrieve the list items

    and I will now set the status to "Modified"

    however when the people picker postsback, the value of status is still "NewForm" so it will again satisfy the first if if (formStatus == "NewForm")


    ----------------------- Sharepoint Newbie

    Thursday, September 26, 2013 6:29 AM