New email and phone fields
Has anyone managed to do a calculation with the new email and phone fields?
@Email or @Phone return unsupported result type
@Email.join() just gives [object Object],[object Object]
I've been using @All of Phone to display contact phone numbers in other related apps
-
Hi Robin,
you've a typo in your code. Between .value} and .join() must be a closing bracket )
var a = @All of email;
a.map(function (obj) { return obj.value}).join()If that doesn't work in the existing calculation field delete it and create a new one (maybe the first one has been saved as number type).
Rainer -
Hi! I have tried a few solutions here and seems to work. The problem I run into is concatenating the fields and one is null:
var a = @Phone;
var b = @Call Back Phone;
var a1=a1 == null ? "" : a1;
var b1=b1 == null ? "" : b1;
a1=a.map(function (obj) { return obj.value}).join().replace(/[^0-9,]/g,"");
b1=b.map(function (obj) { return obj.value}).join().replace(/[^0-9,]/g,"");
[a1,b1].join(',');
Error I get if One is null in PREVIEW: TypeError: Cannot read property'map' of null. They evaluate fine, but if a field is null nothing is returned in the calc field. Any help is appreciated! Thanks! Rob
-
Hi Rob,
var a = @Phone;
var b = @Call Back Phone;
var a1 = a1 == null ? "" : a.map(function (obj) { return obj.value}).join().replace(/[^0-9,]/g,"");
var b1 = b1 == null ? "" : b.map(function (obj) { return obj.value}).join().replace(/[^0-9,]/g,"");
var comma = a != null && b != null ? "," : "";
a1 + comma + b1If you use [a1,b1].join(',') you get a comma if one of of them is null and even if both of them are null (or you need to filter the array with a function for "" before joining it).
Rainer -
Rainer, Awesome as always! Slight mode in your code on var a1=a1 >>> var a1 = a ==.... THANKS!
var a = @Phone;
var b = @Call Back Phone;
var a1 = a == null ? "" : a.map(function (obj) { return obj.value}).join().replace(/[^0-9,]/g,"");
var b1 = b == null ? "" : b.map(function (obj) { return obj.value}).join().replace(/[^0-9,]/g,"");
var comma = a != null && b != null ? "," : "";
a1 + comma + b1
-
Hoping someone can help because I'm having a terrible time with this... When using email to Podio you can only put the to/from into "Email" field types. When you do that, you can wind up with a value of something like.. "other:Joe Smith <joe@smith.com>"
Using tricks found here I can get rid of the "other:" no problem, but I'm left with an email address of "Joe Smith <joe@smith.com>" which is obviously not the email address, but the value of the field without the type label.
How do I take it to the next level to actually extract *just* the email address? joe@smith.com
-
Hi Mark,
do you want to get the "clean" email address in a calculation field or do you want to update the email field?
For updating the email field you need Globiflow.Solution with Globiflow:
When an item is updated
AND Email field changed
Update item
Email Field = Calc str_replace(">","", explode("<", [Email field])[1])In a Podio Calculation field:
var email = @Email.map(function (obj) { return obj.value}).join();
email.split("<").pop().replace(">","")Both solutions are for the case that only one email address is entered. For multiple email addresses in one field you need to create a loop.
Rainer
-
Seems this could be the place to post this question.
I'm trying to find a way to automatically convert a number with no prefix with a prefix.
For example, we have an application form and it asks for peoples number but when they put their numbers in they don't always put +44 so this means I won't be able to send them automated texts.I'd love to set a Globiflow up so that every time a new item is created it checks the contract number and if it doesn't start with +44 it will remove the 0 at the beginning and add +44.
Really looking forward to a solution.
Thanks!
-
Martin Evans
Hi Martin,
the following code should do what you want. It also removes all special characters like () - . etc. and blank spaces from the number.foo(); function foo() {
$number = explode(":",[(Contact) Phone])[1];
$firstDigit = substr($number,0,1);
$add44 = ($firstDigit == "0" ? "+44".substr($number,1) : ($firstDigit == "+" ? $number : ("+44".$number)));return $number != "" && !stristr($number,"N") ?preg_replace("/[\s-()]/","",$add44) : $number;
};
This part: && !stristr($number,"N") is for the case someone enters NA or N/A (for Not Available) in the phone field. You can remove
&& !stristr($number,"N")
if that couldn't happen.
How to use it:Rainer
-
Thanks for that Rainer, however, it didn't work.
I put that calculation in and now it removes the number altogether.
Does it make a difference that I have my numbers in a normal text field and not a phone field as this was the only way I could have the number appear without (work) or (mobile) on PDF's -
Hey Martin,
"Does it make a difference that I have my numbers in a normal text field and not a phone field as this was the only way I could have the number appear without (work) or (mobile) on PDF's"
Yes, that makes a difference.
This line$number = explode(":",[(Contact) Phone])[1];
removes the phone types like "work", "home" from the phone number. It splits work:123456 at the position of the colon and takes the second part (= [1]) for the further calculation - but in your text field is no second part, so it can't take the number.
Change that line to$number = [(Contact) Phone]);
Now it should work.
Btw: With the calculation explode(":",[(Contact) Phone])[1]; you can extract the number from a phone field and use it in a PDF without the phone type in front of it. Just put the code into a variable and then use the token of the variable in the PDF instead the field token.Rainer
-
Hi Rainer,
I tried that but it comes up with Syntax Error.
Heres the full code I used:foo(); function foo() {
$number = [(Applications) Contact Number]);
$firstDigit = substr($number,0,1);
$add44 = ($firstDigit == "0" ? "+44".substr($number,1) : ($firstDigit == "+" ? $number : ("+44".$number)));return $number != "" && !stristr($number,"N") ?preg_replace("/[\s-()]/","",$add44) : $number;
}; -
Hi Nate,
unfortunately you can't set default to any type.
For updating from "work" to "mobile" you need Globiflow:
When an item is created
or
When an item is updated:
update item
phone = Calc str_replace("work","mobile",[phone])
If you import the phone number e.g via Excel you can set it to mobile also if you import via API.
Rainer -
Hi all! This is so helpful. I ended up creating a hidden parsed email field in my podio calc field that uses;
var a = @Email;
var b = a.filter(function (obj) { return obj.value});
b.map(function (obj) { return obj.value}).join()My goal though is to pull these email addresses into Globiflow. I can't seem to figure out how to pull this data. The app is a reference field so it's not showing me anything but the contact's name. Any advice?
-
Hello,
I am using the below for the email address (as before it was returning [object][object]) on an overview table, but if the email address field is empty the full table doesn't load. It only works on tables where the email address field isn't empty. How do I create a 'if field is empty, return as null or "" ?
.map(function (obj) { return obj.value}).join()
Please sign in to leave a comment.
Comments
48 comments