using substring function - InfoPath Dev
in

InfoPath Dev

using substring function

Last post 05-28-2008 08:37 AM by stuck. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-28-2008 05:30 AM

    • stuck
    • Top 150 Contributor
    • Joined on 03-26-2008
    • Posts 74

    using substring function

    Hi all,

    I want to write a formula to extract a substring from one field in my form to a second field.

    so the first field contains links like: \\server\subdir\subdir\subdir\FileName.pdf

     I want to be able to extract only the last bit just before the last "\" so I will be left with only FileName.pdf in the second field. If I can get rid of the .pdf as well then it would be good but if thats too much work then I'll be happy with FileName.pdf

    I would be very gratefule for any help.

     Thanks

     

  • 05-28-2008 06:59 AM In reply to

    Re: using substring function

    This would be a lot simpler if their was any standardization or folder name  or file name structure that could be keyed upon.

    It may be easier to use code since you could parse it from the right instead, I also believe their are some functions alreay created for parsing file paths to get the specific filename.

    However in InfoPath you can nest Substring functions. But again if their are a variable number of folders this can be tough.

    It might be best to have some extra fields to run this through.

    Set Field1 substring-after(substring-before(Field, "."), "\\")

    Set Field2 substring-after(Field1, "\")

    Conditional Contains(Field2, "\") set Field3 substring-after(Field2, "\")

    Conditional Not(Contains(Field2, "\") set FieldFinal Field2

    Conditional Contains(Field3, "\") set Field4 substring-after(Field3, "\")

    You would just need to continue rules on each field for as many as you thought neccessary.

    Not the most elequent but once it is setup would work fine.

  • 05-28-2008 07:18 AM In reply to

    • stuck
    • Top 150 Contributor
    • Joined on 03-26-2008
    • Posts 74

    Re: using substring function

    The structure is somehow standard. \\csdata\DATA_CS\Finance\AccountsPayable\XXX\InProcess\FileName.pdf

    Everything above expect XXX and FileName is variable. Everything else is always the same. So its always the FileName after the InProcess folder that I need to extract.

    would that make it any easier?

  • 05-28-2008 08:37 AM In reply to

    • stuck
    • Top 150 Contributor
    • Joined on 03-26-2008
    • Posts 74

    Re: using substring function

    done it.

     used the substring-after to extract everythying after "InProcess\"

     then substring-before to capture everything before the ".pdf" in the previous field.

    it works :-)

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