Podio Email and Phone Field Calculations

Comments

27 comments

  • Rainer Grabowski

    Hey Aaron,

    which formula do you use?

    Rainer

    0
    Comment actions Permalink
  • Aaron Rice

    @All of Seller Email.map(function (obj) { return obj.value}).join()

    0
    Comment actions Permalink
  • Rainer Grabowski

    Sometimes you have to outwit the preview and to "persuade" the calculation field that the result is a string:

    @All of Seller Email.map(function (obj) { return obj.value}).join() || "abc"
    

    You can do the same if it wants a number

     result || 1
    

    Rainer

    1
    Comment actions Permalink
  • Aaron Rice

    Thank you! That worked like a champ for email. What about phone numbers?

    0
    Comment actions Permalink
  • Rainer Grabowski

    Same way:

    var a = @All of Phone;
    a.map(function (obj) { return obj.value}).join()  || "abc" 
    

    Rainer
    rg@delos-consulting.com

    0
    Comment actions Permalink
  • Teresa Cutrona

    Hello I have quite the same problem.

    I need separate calculation field in Address Map.

    I need just a city

    I use this formula

    @All of Sede Operativa.join().split(",")[1].replace(/[0-9]/g, "").trim()

    but always have this error message: Invalid value - string must be a number

    How can I solve it?

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hey Teresa,

    don't care about this specific "error". Save the template and forget the message.

    Rainer

    0
    Comment actions Permalink
  • Teresa Cutrona

    I moved on but does not show me any results.

    0
    Comment actions Permalink
  • Rainer Grabowski

    Cause it shows you the result "Carlentini" in the preview it will show it also in the item.
    Try a page refresh in the browser. If you have many items in this app it will take a while till all are updated with the calculation.

    0
    Comment actions Permalink
  • Teresa Cutrona

    I refreshed the browser and waited 2 days, but it still not work.

    How can I do?

    0
    Comment actions Permalink
  • Teresa Cutrona

    I tryed to use this formula and now works:

    var stringa = @All of Sede Operativa.join();
    var array = stringa.split(",");
    array[1].trim();


    but how can I use filter inside app instead to use export by excel?

    because I can 't find the field that I need on apposite filter menu.

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hello Teresa,

    your calculation will work only if there's max 1 item related from which you want to pull the city.

    I don't understand your other question:

    but how can I use filter inside app instead to use export by excel?
    because I can 't find the field that I need on apposite filter menu.

    Can explain what you want to filter? And a screenshot would be helpful which shows the fields in the app where you want to pull the data from.  Also an example which result you expect. 

    Rainer

    0
    Comment actions Permalink
  • Mark Cannon

    Hi Rainer,

    I used this post to help me with the same thing Aaron was needing help on, and it worked very well.

    But then I added another app item after the initial 10 or so, and now any new item that I add shows a blank in the fields in which I created the calculation. Below is my exact calculation for one of the fields. I tried refreshing, and after about 20 minutes, it still does not display the information.

    @All of Company Phone Number.map(function (obj) { return obj.value}).join() || "not available"

     

    The app in which the calculation exists pulls the phone numbers from an app of personnel data to which most of our employees don't have access. So, I am using this to provide the public contact information only. I don't think that the access issue would have anything to do with my problem, but thought I'd mention it just in case.

    I used myself as an example and deleted my item in the app containing the calculations. Then I added mine again, and although it was fine before, it doesn't show the information anymore.

    Any ideas?

    0
    Comment actions Permalink
  • Mark Cannon

    Well, I edited the calculation to be separated out line by line, similar to what Teresa did and it worked. When I changed it back, it still worked.

    Not sure what was happening unless it is an issue with calculation refresh schedules, which has been an issue in other areas also.

    0
    Comment actions Permalink
  • Rob Badhorn

    Hi Rainer,

    I use this formula because I could have more than one contact (App B) related to App A.

    var a = @Phone;
    a.map(function (obj) { return obj.value}).join().replace(/[^0-9]/g,"") || ""

    I use it to pull the phone numbers.  Is there a way to seperate the Phone Numbers with a comma?  like Theresa (I know its max 1 related)

     

    Thanks! Rob

     

    1
    Comment actions Permalink
  • Rainer Grabowski

    Hi Rob,

     .join() returns the numbers as they have been entered (with blanks brackets, dashes or the international +) as a comma separated string,

    .replace(/[^0-9]/g,"") removes everything from that string except (= ^) the digits. Everthing you want to be kept you have to add inbetween []. If you want to keept the comma: .replace(/[^0-9,]/g,"")

    Rainer

    0
    Comment actions Permalink
  • Rob Badhorn

    Hi Thanks Rainer,  I think I am confused myself therefore confused you.  Sorry about that.

    I do want to obliterate everything Except the Numbers in a PHONE field in an App.

     

    Formula: 

    var a = @Phones;

    a.map(function (obj) { return obj.value}).join().replace(/[^0-9]/g,"")  || ""

     

    The formula above Brings multiple Phone numbers i.e. WORK (222-333-4444), MOBILE (333) 444-5555

    equals: 22233344443334445555

    I would like: 2223334444,3334445555  Possible?

    Thanks! Rob

     

     

     

    0
    Comment actions Permalink
  • Rainer Grabowski

    Yes possible. As I wrote: Just add a comma behind the 9 in the replace function: .replace(/[^0-9,]/g,"").

    a.map(function (obj) { return obj.value}).join().replace(/[^0-9,]/g,"")  || ""
    0
    Comment actions Permalink
  • Rob Badhorn

    Awesome!  Works of course.  Thanks!

    0
    Comment actions Permalink
  • Kevin Oechsel

    Is there any way to eliminate anything before and anything after the actual 10 digit phone number (including all formatting, etc.)

    For example

    Take a phone number with all formatting and extra numbers/figures (+1, ext. 05).......

    +1 (111) 222-3333 ext. 05

    and have it return just the numbers 

    1112223333

    1
    Comment actions Permalink
  • Rainer Grabowski
    @phone.map(function (obj) { return obj.value}).join().replace(/[^0-9]/g,"").substr(1,10)
    1
    Comment actions Permalink
  • Claudio Acevedo
    Hi Rainer,
    what if i wanted to add a "1" in front of the phone # for the country code?

    @
    phone.map(function (obj) { return obj.value}).join().replace(/[^0-9]/g,"").substr(1,10)
    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Claudio,

    @Phone.map(function (obj) { return "1" + obj.value.replace(/[^0-9]/g,"").substr(0,10);}).join()

    Rainer

    0
    Comment actions Permalink
  • Claudio Acevedo

    Thanks Rainer!

    0
    Comment actions Permalink
  • Maxton max

    hello I have some problem here

    var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

     


    var email = @Email.map(function(obj) {return obj.value}).join();
    var string = email.split(",");

    var len = string.length;

    var arr = [];
    var i, result, e;


    for (i = 0; i < len; i++) {

    e = re.test(string[i].toLowerCase());

    if (email === null) {
    result = "*Enter an Email Address in the **Email** Field to Validate*";
    } else if (email !== null) {

    if (e == 1) {
    result = "*Email Validation Passed*";
    } else {
    result = "**The Email Address You Have Entered Is Not Valid**";
    }


    }
    arr.push(result);
    }

     

    when I try to run this code it always return just a number. not showing email addresses

    help me to solve this

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Maxton, 

    the number you get is the number of items in the array. You must parse the array to a string (.toString() or .join()).  Also you can simplify your code a bit. And if you've multiple addresses in the email field you should show the user which address is valid/not valid (for that I've put email[i] before the result of the validation check in var singleResult)

    var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    var email = @Email.map(function(obj) {return obj.value});
    var len = email.length;
    var i, result, singleResult,e;
    if (email == null) {
         result = "*Enter an Email Address in the **Email** Field to Validate*";
    } else {
      arr = [];
      for (i = 0; i < len; i++) {
           e = re.test(email[i].toLowerCase());
           singleResult =  email[i] + ":  "  + (e == 1 ?  "*Validation Passed*" :  "**Not Valid**";
          arr.push(singleResult);
      };
      result = arr.join();
    };
    result

    Rainer

    0
    Comment actions Permalink
  • Benjamin L. Lambourne

     Hey Rainer, 

    I saw You Had Answered Some Questions in Regards to the Phone Number Being Formatted in this Post. The Post itself was super helpful, and I have implemented what you recommended. It works great of course. 

    I was hoping you could help me do the reverse formatting, so

     

    111-111-1111

    1111111111

    Any Variation

    Shows As = (111) 111-1111

     

    Thanks,

     

    -Ben                                                                                                      

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk