Need To Prepend data to filename BEFORE it is saved to SharePoint library - InfoPath Dev
in

InfoPath Dev

Need To Prepend data to filename BEFORE it is saved to SharePoint library

Last post 12-02-2013 10:23 AM by Deeayrian. 24 replies.
Page 2 of 2 (25 items) < Previous 1 2
Sort Posts: Previous Next
  • 09-17-2012 09:21 PM In reply to

    Re: Need To Prepend data to filename BEFORE it is saved to SharePoint library

     Thanks Hilary. I appreciate your effort. I got your email. The file was not attached (probably got stripped) so thanks for placing it here.

    I see you ran into the same problem I did. Your sample xsn allows for ONE file to be attached and, yes the ICMNO is concatenated - so that part was good.

    If you attach another file you lose the reference from the first.

    My objective was to allow for multiple file attachments and each would be concatenated with the ICMNO, preferable with one click of the submit.

    I even tried to give up that idea and just tell the user to click the submit button each time a file was attached. That did not work out either.

    I then tried to take your example and make the Attachment a repeating field. As I pointed out in the previous posts, that did not work because the GetAttachmentAttribute only works ONCE.

    The second and subsequent executions grab the first /name value.I tried putting the GetAttachmentAttribute inside the repeating Attachment group and outside. Outside, it grabs the first results every time, inside, the 2nd and subsequent submits... it draws a blank - as you can see in the illustration.



    DMN
  • 09-18-2012 07:33 AM In reply to

    Re: Need To Prepend data to filename BEFORE it is saved to SharePoint library

    I modified Jo-Anne's sample for a repeating file attachment field. Please see attached. The file name is now generated by rules on the file attachment node.

    Hilary Stoupa

  • 09-18-2012 07:38 AM In reply to

    Re: Need To Prepend data to filename BEFORE it is saved to SharePoint library

     thanks Hilary !

    I'll check it out this morning and get back to you.

    DMN
  • 09-18-2012 09:17 AM In reply to

    Re: Need To Prepend data to filename BEFORE it is saved to SharePoint library

     Hilary, I'm working on it now. When I try to build the concat function, I get the error:

    "preceding-sibling::FileAttachment" does not point to a valid location path of a field or group.

    Here is a copy/paste of my formula:

    concat("GetAttachmentAttribute /xpath=/my:myFields/my:Attachments/my:Attachment/my:FileAttachment[", count(preceding-sibling::FileAttachment) + 1, "] /attr=Name")

    Admittedly I have never used the 'preceding-sibling' attribute of the count function, so it quite likely I am not building that part of the formula correctly.

    I just typed it in to replicate what you had. I'm thinking that is where I am going wrong ??

    thanks.

     

    DMN
  • 09-18-2012 09:22 AM In reply to

    Re: Need To Prepend data to filename BEFORE it is saved to SharePoint library

    Before you copy/paste the formula, select the edit XPath check box. In my form, the formula is actually: count(preceding-sibling::my:FileAttachment)

    Hilary Stoupa

  • 09-18-2012 12:24 PM In reply to

    Re: Need To Prepend data to filename BEFORE it is saved to SharePoint library

     thanks Hilary. I always forget to click that edit xpath to check the formula.

    I used your XSN and modified it to point to my attachments library. Otherwise, it's the same.

    Did you get the same results?

    The end results that show up in the Attachments library are 2 documents with the same name. I didn't make any changes other than the SaveToSharePoint to point to my library. I had to make 2 posts so I could get all the screen captures. This post show the forms input screen capture and an insert to show the Attachments library results.

    The next post breaks out all the rules you created. I copy/pasted the formulas after checking the Edit XPath (advanced) option so you can verify what I have in those values.

    Still not working quite right. The customFileName is getting updated as I would hope, but it is not getting into the file name that is sent via the SaveToSharePoint command.

    I've executed it two ways as pointed out in the image attached to this post.


    DMN
  • 09-18-2012 12:25 PM In reply to

    Re: Need To Prepend data to filename BEFORE it is saved to SharePoint library

     POST 2 of 2 ... to get the rest of the images uploaded (reference previous post)


    DMN
  • 09-18-2012 12:30 PM In reply to

    Re: Need To Prepend data to filename BEFORE it is saved to SharePoint library

    The problem is you are using a full path to the name field. My apologies - I didn't bother changing the save command in the form. Should be: /nameXPath=@my:customFileName instead of using the absolute XPath.

    Hilary Stoupa

  • 09-18-2012 12:52 PM In reply to

    Re: Need To Prepend data to filename BEFORE it is saved to SharePoint library

     no problem. I'm so glad you caught that.

    BINGO !!   EUREKA!!  "I love it when a plan comes together"...  and all those other things people say when success is achieved.

    This is exactly what I need. I love it. It works whether the user attaches a file and hits Submit or adds 2 or more attachments and then hits submit.

    I tested creation of a new form and updating an existing. WORKS GREAT !!!!!!!!!

    Thanks so much for hanging in there with me and putting up with my badgering.

    DMN
  • 12-02-2013 10:23 AM In reply to

    Re: Need To Prepend data to filename BEFORE it is saved to SharePoint library

    Is this solution to rename an attachment before saving it, possible for saving attachments to list items (rather than in a library as this example shows)?

    Here is my issue.  I am saving attachments from a form to a list.  Thanks to your forums, I have figured out how to check for invalid characters in the file name and then notify the person the file has invalid characters.  But is it possible for me to automatically change the file name so that it saves the file without the invalid characters?   In this example, you assign /nameXPath to the SaveToSharePoint command. but I am not sure there is a way to do that for the SubmitToSharePointList command with dsname=/AddAttachment at the end. 

     

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