Substring and concatenate a phone number
Hi guys Avatar
I've been trying trying to do this a number of wasy with calculated fields and its not working - can anyone help?
I'm trying to take a local mobile phone number (@phone field in podio) entered by the customer as '0411222333'
then 1. substring the last 9 digits eg. '411222333'
then 2. add in the international code for Australia '61' so it becomes a full international dialing number eg. '61411222333' - so it can then be used by Twilio etc.
Can anyone please help?
Thanks so much.
Troy
-
Hi Troy,
I assume, the phone number is in a phone field, not in a a text field. If so, you can do:
var fon = @phone field.map(function (obj) { return obj.value}).join(); "61" + fon.substr(-9)
Rainer
rg@delos-consulting.com -
Thanks Rainer - this is copied and pasted from the calculation field direct:
var fon = @Phone field.map(function (obj) { return obj.value}).join();
"61" + fon.substr(-9)I've also tried...
var fon = @Phone field.map(function (obj) { return obj.value}).join();
'61' + fon.substr(-9)and also....
var fon = @Phone field.map(function (obj) { return obj.value}).join();
'61'+fon.substr(-9)They all still get the same script syntax error :(
-
Hi Troy,
can you share a screenshot (maybe as a link) with the phone field and the calculation field (like the one I've posted)?Did you try the code in a new calculation field? Maybe that helps. "Unexpected identifier" normally means that there is some wrong with the var name like "ver fon" or "var f on". But it's strange in your case, cause I've copy exactly waht you've posted into my calculation and it works.
-
Thanks Rainer - I've had to figure a way around this using zapier.com - between my form and Podio - to transform the data. That seems to work now.
It's very strange that I couldn't get it to work within Podio, but none the less i have the outcome required.Thanks so much for your help.
Please sign in to leave a comment.
Comments
9 comments