locked
Adding multiple rows to a repeating table based on a number value in another repeating table RRS feed

  • Question

  • I have 2 repeating tables - one for general inventory that collects the number of desktops, laptops, servers and printers (drop down with manual entry of device types and a text box for quantities of each) we are recycling and then a detailed inventory that the user will input the serial numbers for.  For example:

    General Inventory:

    desktop Qty. 2

    laptop Qty. 3

    I want to automatically add the rows in the detailed inventory to capture the number of serial numbers from the general inventory.

    Detailed Inventory:

    desktop 1 - S/N ABC

    desktop 2 - S/N BCD

    laptop 1 - S/N CBA

    laptop 2 - S/N BCA

    laptop 3 - S/N DEF

    I'm just starting with coding in InfoPath, though I do have experience with C# so I'm not afraid to try some backend coding.

    Any assistance is appreciated.

    Wednesday, January 21, 2015 10:32 PM

Answers

  • Hello,

    You can add rows using "WriteElementString" method in infopath form. Basically you need to first read first table and get the count then loop & bind rows in another table based on first table value. Here is the sample code to add rows by code:

    http://www.bizsupportonline.net/infopath2007/programmatically-add-row-repeating-table-xmlwriter.htm

    Let us know if you need more help


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

    • Marked as answer by Victoria Xia Tuesday, February 10, 2015 2:57 AM
    Thursday, January 22, 2015 6:23 AM
  • Hi

    i recommend another approach.

    The main list will be dthe detailed inventory list, in which you add item by item : equipment, type, S/N , RAM, ..... and so on, also you can have columns like , user, and most importatnt STATUS

    Status , a choice column like: NEW, inUSE, BAD....

    Based on this main list, you can summarize ( using a scheduled powershell script or using an attached workflow to main list, ) the number/ based on different choices: type, status..... and store these values in separate list


    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

    • Proposed as answer by VikashKummar Thursday, January 22, 2015 9:01 AM
    • Marked as answer by Victoria Xia Tuesday, February 10, 2015 2:57 AM
    Thursday, January 22, 2015 6:57 AM
  • If I can't get it to work the other way I may just do that where it summarizes the list instead. Thanks.
    • Marked as answer by Victoria Xia Tuesday, February 10, 2015 2:57 AM
    Thursday, January 22, 2015 9:56 PM

All replies

  • Hello,

    You can add rows using "WriteElementString" method in infopath form. Basically you need to first read first table and get the count then loop & bind rows in another table based on first table value. Here is the sample code to add rows by code:

    http://www.bizsupportonline.net/infopath2007/programmatically-add-row-repeating-table-xmlwriter.htm

    Let us know if you need more help


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

    • Marked as answer by Victoria Xia Tuesday, February 10, 2015 2:57 AM
    Thursday, January 22, 2015 6:23 AM
  • Hi

    i recommend another approach.

    The main list will be dthe detailed inventory list, in which you add item by item : equipment, type, S/N , RAM, ..... and so on, also you can have columns like , user, and most importatnt STATUS

    Status , a choice column like: NEW, inUSE, BAD....

    Based on this main list, you can summarize ( using a scheduled powershell script or using an attached workflow to main list, ) the number/ based on different choices: type, status..... and store these values in separate list


    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

    • Proposed as answer by VikashKummar Thursday, January 22, 2015 9:01 AM
    • Marked as answer by Victoria Xia Tuesday, February 10, 2015 2:57 AM
    Thursday, January 22, 2015 6:57 AM
  • Thanks for the link! I was looking at similar articles but wasn't sure which was the best approach.

    I am trying to accomplish this without adding a button if possible. I want the form to be as intuitive as possible for the users so that I can add validation to the form for mandatory fields (if they say 3 desktops, they have to have 3 sets of details for desktops kind of thing). I suppose instead of doing it on a Click event I could do it on a validation event on the Qty field where if the type = desktops and the qty >1 than add rows?

    Thursday, January 22, 2015 9:55 PM
  • If I can't get it to work the other way I may just do that where it summarizes the list instead. Thanks.
    • Marked as answer by Victoria Xia Tuesday, February 10, 2015 2:57 AM
    Thursday, January 22, 2015 9:56 PM