Function and Code Help? - InfoPath Dev
in

InfoPath Dev

Function and Code Help?

Last post 11-27-2010 10:38 PM by Jimmy. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 11-26-2010 10:18 PM

    Function and Code Help?

    I read on a forum how to make a phone number come back in a particular format using the following:

     

    concat("(", substring(translate(., "()-. ", ""), 1, 3), ") ", substring(translate(., "()-. ", ""), 4, 3), "-", substring(translate(., "()-. ", ""), 7, 4))

     

    My problem is that I dont understand this and more so , I need to do it for a zipcode as well. To make a long story short, I want to understand it and I would like some help by explaining how i can do the above from scratch for Zipcodes...and maybe emails. Thanks

  • 11-27-2010 10:38 PM In reply to

    Re: Function and Code Help?

    Each of the places where you see translate(., "()-. ", "") is producing a temporary copy of the original value with all the parentheses, dashes, periods, and spaces removed.  Then each substring() around those is taking that stripped-down value and extracting a certain portion of it.   So substring(translate(., "()-. ", ""), 1, 3) produces the first 3 characters of the field value after all the parentheses, dashes, periods and spaces are removed, and substring(translate(., "()-. ", ""), 4, 3) produces the 3 characters of this stripped-down value, starting at the 4th character.  The outer concat() function strings these extracted parts together, interspersing them with formatting characters, in this case "(", ") ", and "-".

     Does that make it clearer for you?

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