Checking for invalid characters in file name for multiple files - InfoPath Dev
in

InfoPath Dev

Checking for invalid characters in file name for multiple files

Last post 12-09-2013 11:58 AM by Deeayrian. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 12-09-2013 07:02 AM

    Checking for invalid characters in file name for multiple files

    I have a file attachment control, in a repeating section so that there can be more than one, that need to be saved to a SharePoint list.  I have it set up so that when an end user attaches a file with an invalid character in the file name, they will receive a message letting them know they have to rename the file before they can attach it and then the rule removes the file from the attachment field (leaving it blank).  I can get this to work great on the first file attachment, but if there are multiple attachments, the rule doesn't work on anything after the first attachment. 

    Here's how I did it:  I set a rule on the file attachment control that when it changes, to set the qRules Command field to: concat("GetAttachmentAttribute /xpath=/my:myFields/ my:attachmentsSection/my:group19/my:Attachments/my:attachment [", count(preceding-sibling::Attachments/attachment) + 1, "] /attr=Name")  then I set the Name field to result.  As mentioned, it works perfectly on the first file attached, but when I try it on the 2nd file attached, the error in the Qrules error field reads "Failed to select the attachment node.". 

     Any ideas?

  • 12-09-2013 10:09 AM In reply to

    Re: Checking for invalid characters in file name for multiple files

    Hi-

    From this xpath:

    /my:myFields/ my:attachmentsSection/my:group19/my:Attachments/my:attachment

    Which is the repeating node?

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 12-09-2013 11:26 AM In reply to

    Re: Checking for invalid characters in file name for multiple files

    The repeating node is Attachments.  See screen shot that I have attached.

    I did try changing my command to this: concat("GetAttachmentAttribute /xpath=/my:myFields/ my:attachmentsSection/my:group19/my:Attachments/my:attachment [", count(preceding-sibling::Attachments) + 1, "] /attr=Name")   but it still gave me the same error.


  • 12-09-2013 11:40 AM In reply to

    Re: Checking for invalid characters in file name for multiple files

    Since the repeating node is my:Attachments, then that's the node that needs the [] (square brackets)

    /my:myFields/ my:attachmentsSection/my:group19/my:Attachments[1]/my:attachment

    /my:myFields/ my:attachmentsSection/my:group19/my:Attachments[2]/my:attachment

    etc.

    Does that makes sense?

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 12-09-2013 11:58 AM In reply to

    Re: Checking for invalid characters in file name for multiple files

    Yes that makes perfect sense.  Wish I would've realized that hours and hours ago! 

    I changed it to read: concat("GetAttachmentAttribute /xpath=/my:myFields/ my:attachmentsSection/my:group19/my:Attachments[", count(preceding-sibling::Attachments) + 1, "]/my:attachment /attr=Name")

    and it works perfectly!  Thank you so much Ernesto!

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