Need to automatically add row to a repeating table if <some filed is not blank> - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Need to automatically add row to a repeating table if <some filed is not blank>

Last post 12-21-2011 01:40 AM by Brokholm. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 01-13-2009 02:24 PM

    Need to automatically add row to a repeating table if <some filed is not blank>

    The following code (on click of a button) works perfectly for me to delete a row from a repeating table : var thisNode = eventObj.Source.selectSingleNode("."); thisNode.parentNode.removeChild(thisNode) I need something exactly like this but which will ADD an row to a repeating table. Clicking the" Insert Item" or button is not an option. Basically I want to add a row to a repeating table as soon as some other field (not a part of the repeating table) is populated. If it can be done without code, even better!!! Can you help me please? Infopath 2003 and JScript.
  • 01-14-2009 02:18 AM In reply to

    Re: Need to automatically add row to a repeating table if <some filed is not blank>

    You need to access this Manifest file, the following line shows how to get e newRow node 

    XPathNavigator xnNode = this.Template.Manifest.SelectSingleNode("//xsf:xDocumentClass/xsf:views/xsf:view/xsf:editing/xsf:xmlToEdit[@name='NameNodeInManifest']/xsf:editWith/xsf:fragmentToInsert/xsf:chooseFragment/my:RepeatingNode", this.NamespaceManager);

     So first you Save as source file, go to the manifest:xsf en try to find the NameNodeInManifest, This will be the nodename with a number

    After the first part of the code, append the new structure, when you delete the complete range, InfoPath doesn't know the structure anymore

    xnGroupNode.SelectSingleNode("/my:expenseReport/my:MyControls", this.NamespaceManager).AppendChild(xnNode.InnerXml);

    //-- Get the newest appended node --
    xnNewRow = xn.SelectSingleNode("/my:expenseReport/my:MyControls/my:MyControl[last()]", this.NamespaceManager);

    // Add the data to the new row 
    xnNewRow.SelectSingleNode(
    "my:Source", this.NamespaceManager).SetValue("some data")

    Hope this will help you

    Frederik Van Lierde
    Blue InfoPath Blog  ¦  SilverSands Associate  ¦  Do you follow me already?  ¦  We work smart, not hard


    If this article was helpfull, don't forget to rate it, tnx!
  • 01-14-2009 02:48 AM In reply to

    Re: Need to automatically add row to a repeating table if <some filed is not blank>

    You can add a row to a repeating table with the following single line of code:

     XDocument.View.ExecuteAction("xCollection::insert", "group2_1")

    just replace group2_1 with the XMLToEdit value found on the Advanced tab of the repeating table's properties.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-14-2009 07:54 AM In reply to

    Re: Need to automatically add row to a repeating table if <some filed is not blank>

    BULLS EYE!!! Thanks for this line Jimmy... it has been a huuuge help!!!
  • 01-14-2009 07:57 AM In reply to

    Re: Need to automatically add row to a repeating table if <some filed is not blank>

    Hi Frederik, I would have gone with your solution but Jimmy's one liner saves a lot of work :) - lazy that I am! But thanks a lot anyways! Really appreciate it.
  • 03-03-2009 09:29 AM In reply to

    Re: Need to automatically add row to a repeating table if <some filed is not blank>

    Jimmy:

    You can add a row to a repeating table with the following single line of code:

     XDocument.View.ExecuteAction("xCollection::insert", "group2_1")

    just replace group2_1 with the XMLToEdit value found on the Advanced tab of the repeating table's properties.

    When I try this I get the following unhelpful error:

    The following error occured:

    InfoPath has encountered an error. The operation failed.
    The form's code contains an error.

    The following call in the form's code failed: View.ExecuteAction
    Unspecified error

    The line that causes the fault is:  XDocument.View.ExecuteAction "xCollection::insert", "UID_4"
    (There are no parenthesis because this form was developed using VBS)

    I have absolutely no idea what this could mean. The only things I can think that might affect it are that I have only just switched to the view when I try to call it... and UID_4 is a repeating section within another repeating section.

  • 01-28-2010 09:38 PM In reply to

    Re: Need to automatically add row to a repeating table if <some filed is not blank>

    Jimmy, Your posts are great resources for the codeless newbie!

    Question, does this work in browser forms and can this be a single line of code added to a button outside of the repeating table?

    I have a complicated senario i'm working through, where I want to use multiple dropdowns and populate one repeating table. (sum of dropdowns if you will).  With one button click I would like to take the dropdown field and copy it to the next available line in the repeating table. Similar to the "insert item" command in the table but via a button. Everyone complains about the size of the insert and its not intuitive as a button would be to set the data to the repeating table. The proplem with the current button is it writes to the table but it repeats the entire column.

    Is there a better way to consolidate dropdown selections into one "repository" so I only promote this consolidated table when the form is publised and my work flow only needs to look at one single. multiple lines of text content type.

    Can you follow me?

  • 12-21-2011 01:40 AM In reply to

    Re: Need to automatically add row to a repeating table if <some filed is not blank>

    Hi Jimmy

    I am trying to get this code to work without using a button. I have a repeating table used to keep track of a review process. The table contains 3 fields, a date (date of the review), a result field (drop down) and a rich text box used to include action items/ changes needed for approval.

    The result field (drop down) has 3 possible selections: Unconditional approval, Conditional approval and No approval. If the review ends with no approval I would like to insert a new row in the table to allow planning of a new review. I have previously used alot of sections and then just hidden them unless they were needed because the previous reviews ended with the result: No approval. However this looked a bit messy.

    I can get the code to work as a "Changed event". However it gets stuck in an infinite loop and inserts 15 lines or so. Could you by chance tell me how this could work?

     Best regards

    Dennis

Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.