Generating Filename - InfoPath Dev
in

InfoPath Dev

Generating Filename

Last post 04-29-2009 06:56 AM by klc2009. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 04-28-2009 10:19 AM

    Generating Filename

    First let me say that I am a complete newbie to InfoPath and that I am using it in combination with Sharepoint to design and implement a document management strategy. I am not a developer by any stretch, so would prefer not to attempt to use code if possible.  

    I am using InfoPath 2007. I have a template part that I am building where I have a button to Generate Filename that uses this function:

    concat(DocType, "-", ISOFolderNum, "-000", DocNum)

    And this works fine until I get to larger DocNums, when I want the number of 000s to change accordingly. For instance, since my first DocNum is 1, the filename generated now is WI-10-0001. But when I get to DocNum 10, the way it is set up now the filename will be WI-10-00010 but what I want it to be is WI-10-0010.

    How can I accomplish this? Thanks in advance for any help.

    klc2009

  • 04-28-2009 12:27 PM In reply to

    As you may well know, the problem arises from those static zeros you have. A rule would make it more dynamic. For example, by taking the length of the DocNum, you can determine how many zeros you want. Something like, if length(DocNum) > 2 then use the following forumla concat(DocType,"-",ISOFolderNum,"-00",DocNum). Then if length(DocNum) > 3 then you would have another formula that would remove another zero.

    I hope this makes sense.

  • 04-28-2009 01:20 PM In reply to

    Thank you for your feedback and it does make sense. However, if it's possible to add an if statement to the button formula, I can't figure out how to do it. :( I don't think I need the length function, as I can just check if the value is less than 10, less than 100 etc, correct? But any syntax I try for an if statement is rejected.

  • 04-28-2009 02:18 PM In reply to

    You could try to compare the value being less than a specific amount, however, you would have to structure your rules in a way to avoid logic errors. For example, if you had three rules: if x is less than 100, if x is less than 10, etc., you would have to set the rules that work with higher numbers first. For example, 1 is less than 10, but it's also less than 100, so which value would it receive? I prefer to use the string length, that way I know that 2 digits will always produce numbers between 10-99, three digits 100-999, etc. Sorry, if this is confusing!

    You're right, infopath doesn't have an "if-then" statement, but I created a simple expression that would handle this. I used the following expression as my condition:

    string-length(xpath of DocNum) = 2

    Then if the DocNum had 2 digits I would set the following value in the text field:

    concat(DocType,"-",ISONum,"00-",DocNum)

    If DocNum had 3 digits then I would set the same value, but with one zero less.

    You would need three or so rules to get your results. I hope this makes sense!!

  • 04-28-2009 11:12 PM In reply to

    Check out the eval function.

    Patrick Halstead
    Project Manager at Qdabra
  • 04-29-2009 06:56 AM In reply to

    string-length(xpath of DocNum) = 2

    Then if the DocNum had 2 digits I would set the following value in the text field:

    concat(DocType,"-",ISONum,"00-",DocNum)

    If DocNum had 3 digits then I would set the same value, but with one zero less.

     

     

    Thank you very much, this worked perfectly!

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