Repeating Section - InfoPath Dev
in

InfoPath Dev

Repeating Section

Last post 02-26-2010 12:02 AM by Lawson. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 02-25-2010 11:40 AM

    • Lawson
    • Top 100 Contributor
    • Joined on 12-24-2009
    • Virginia
    • Posts 91

    I have an IP form with an attachment control within a repeating section and a save button outside of the repeating section. When an attachment is added, the save button can be use to save the attachment to a predefined path. However, when the repeating section is used, the save button only saves the first attachment and none of the attachments that have been created with the repeating section.

     

    Is there any way to save the other attachments that have been created with the repeating section?

     

    I have added my form to this post for reference.

    Thanks,

    -Lawson

     

  • 02-25-2010 08:10 PM In reply to

     You should use the selectNodes method instead of selectSingleNode, and then iterate through the results (you can use a foreach loop), saving one file each time the loop iterates.  You will need to come up with a scheme for differentiating the file names.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-25-2010 08:39 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-24-2009
    • Virginia
    • Posts 91

    Can you give me an example that points me in the right direction on how to do this?

  • 02-25-2010 10:12 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-24-2009
    • Virginia
    • Posts 91

    I tried you the foreach loop with the following code:

     

    IXMLDOMNode n = thisXDocument.DOM.selectNodes("/my:myFields/my:group1/my:group2/my:field1");

    //Get the text of the node.

    String field1 = n.text;

    foreach (IXMLDOMNode selectnodes in selectnodes)

    if (field1.Length > 0)

    {

    InfoPathAttachmentEncoding.
    InfoPathAttachmentDecoder myDecoder = new InfoPathAttachmentEncoding.InfoPathAttachmentDecoder(field1);myDecoder.SaveAttachment(@"C:\Users\Lawson\Documents\Category A\A1-Acquisition Plan");

    }

     

     But I get the following errors:

    Error 1 Cannot implicitly convert type 'Microsoft.Office.Interop.InfoPath.SemiTrust.DOMNodeList' to 'Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMNode'. An explicit conversion exists (are you missing a cast?) C:\Users\Lawson\Desktop\eFileroom\AttachmentEncoding\AttachmentEncoding\Code Files\FormCode.cs 58 29 AttachmentEncoding

    Error 2 The name 'selectnodes' does not exist in the current context C:\Users\Lawson\Desktop\eFileroom\AttachmentEncoding\AttachmentEncoding\Code Files\FormCode.cs 61 49 AttachmentEncoding

     

    Can you tell me where I'm going wrong?

     

    Thanks for your help,

    -Lawson

     

     

     

  • 02-25-2010 10:23 PM In reply to

     The first line should have DOMNodeList, not IXMLDOMNode.

    The foreach line should be something like:

    foreach(IXMLDOMNode node in n)

    and then you should replace "field1" with "node" in these lines:

     if (field1.Length > 0)

     InfoPathAttachmentEncoding.InfoPathAttachmentDecoder(field1);

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-25-2010 10:50 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-24-2009
    • Virginia
    • Posts 91

    I made the suggested changes.

    //Get a reference to the attachment node.

    DOMNodeList n = thisXDocument.DOM.selectNodes("/my:myFields/my:group1/my:group2/my:field1");

    //Get the text of the node.

    String field1 = n.text;

    foreach (IXMLDOMNode node in n)

    if (node.Length > 0)

    {

    InfoPathAttachmentEncoding.
    InfoPathAttachmentDecoder myDecoder = new InfoPathAttachmentEncoding.InfoPathAttachmentDecoder(node);myDecoder.SaveAttachment(@"C:\Users\Lawson\Documents\Category A\A1-Acquisition Plan");

    }

     

    But I get the following errors:

    Error 1 'Microsoft.Office.Interop.InfoPath.SemiTrust.DOMNodeList' does not contain a definition for 'text' C:\Users\Lawson\Desktop\eFileroom\AttachmentEncoding\AttachmentEncoding\Code Files\FormCode.cs 60 31 AttachmentEncoding

    Error 2 'Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMNode' does not contain a definition for 'Length' C:\Users\Lawson\Desktop\eFileroom\AttachmentEncoding\AttachmentEncoding\Code Files\FormCode.cs 62 22 AttachmentEncoding

    Error 3 The best overloaded method match for 'InfoPathAttachmentEncoding.InfoPathAttachmentDecoder.InfoPathAttachmentDecoder(string)' has some invalid arguments C:\Users\Lawson\Desktop\eFileroom\AttachmentEncoding\AttachmentEncoding\Code Files\FormCode.cs 64 82 AttachmentEncoding

    Error 4 Argument '1': cannot convert from 'Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMNode' to 'string' C:\Users\Lawson\Desktop\eFileroom\AttachmentEncoding\AttachmentEncoding\Code Files\FormCode.cs 64 139 AttachmentEncoding

    Thanks for your help,

    -Lawson 

     

  • 02-25-2010 11:29 PM In reply to

     Remove this line:

    String field1 = n.text;

    Make the following two changes:

     if (node.Length > 0)  --> if (node.text.Length > 0)

     InfoPathAttachmentDecoder(node); --> InfoPathAttachmentDecoder(node.text);

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-25-2010 11:39 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-24-2009
    • Virginia
    • Posts 91

    I made the suggested changes.

    DOMNodeList n = thisXDocument.DOM.selectNodes("/my:myFields/my:group1/my:group2/my:field1");

    //Get the text of the node.

     

    foreach (IXMLDOMNode node in n)if (node.text.Length > 0)

    {

    InfoPathAttachmentEncoding.InfoPathAttachmentDecoder myDecoder = InfoPathAttachmentDecoder(node.text);

    myDecoder.SaveAttachment(@"C:\Users\Lawson\Documents\Category A\A1-Acquisition Plan");

    }

    But I get the following error:

     

    Error 1 The name 'InfoPathAttachmentDecoder' does not exist in the current context C:\Users\Lawson\Desktop\eFileroom\AttachmentEncoding\AttachmentEncoding\Code Files\FormCode.cs 68 86 AttachmentEncoding

    Thanks for the late night help,

    -Lawson

  • 02-25-2010 11:50 PM In reply to

    You eliminated the end of this line

    InfoPathAttachmentEncoding.InfoPathAttachmentDecoder myDecoder = new

    and the beginning of this line

    InfoPathAttachmentEncoding.InfoPathAttachmentDecoder(node);myDecoder.SaveAttachment(@"C:\Users\Lawson\Documents\Category A\A1-Acquisition Plan");


     that were present in your previous post.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-25-2010 11:58 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-24-2009
    • Virginia
    • Posts 91

    Yep, made the changes, and it works great.

    Thanks for all your help man!

    My bulldog says the same...

  • 02-26-2010 12:02 AM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-24-2009
    • Virginia
    • Posts 91

    Since you’re up, I’ve got a different question.

    If you have some time, maybe you can point me in the right direction.

    I need to create a button that converts the contents of textboxes on a form to a .csv file and saves the .csv file to a specified path.

     

    Do you know how to do this???

     

    THanks

    -Lawson

     

     

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