Leading Zeros for infopath 2010 browser form - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Leading Zeros for infopath 2010 browser form

Last post 10-28-2011 03:27 AM by Jimmy. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 10-27-2011 02:11 PM

    Leading Zeros for infopath 2010 browser form

    I have read through most of these posts and am still having issues with getting a leading zero to work.

    I have InfoPath 2010 form called CRequest3 (atttached)that is being pulled up and filled out in SharePoint.

    I have a field called docSiteID it has to have 3 digits, if a 2 digit number is entered, a leading zero must be added to the field. -we use the data to run reports and a 3 digit number is a must otherwise it errors out.

    I have tried many types of function from your sheets, I guess since I am so new at this I am not understanding how to fill out the boxes correctly. 

    Please help me.

     

  • 10-27-2011 04:17 PM In reply to

    Re: Leading Zeros for infopath 2010 browser form

    This can be done by adding two seperate rules to the text box that you are using. I've noticed this only works if the text box is set to a String type and not for Integer type text boxes. At least this is the case in Infopath 2007

    Rule 1: Condition - If field1 matches the pattern \d (this means one integer)

               Action: Set field1's value to this expression - concat("00",/my:myFields/my:field1)

    Rule 2: Condition - If field1 matches the pattern \d\d (this means two integers)

               Action: Set field1's value to this expression - concat("0",/my:myFields/my:field1)

     I've attached a sample form that will do this for you. I also added some data validation to the field to ensure there cannot be more that three numbers in the field.

     

  • 10-28-2011 03:27 AM In reply to

    Re: Leading Zeros for infopath 2010 browser form

    This formula should also work for adding leading zeros to make three digits:

    concat(substring('000', 1, 3 - string-length(field)), field)

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.