Substring and concatenate a phone number

Comments

9 comments

  • Rainer Grabowski

    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

    1
    Comment actions Permalink
  • Troy Muir

    Thanks very much or your response Rainer - Unfortunately it's returning the below error:
    "script syntax error: Unexpected identifier"

    0
    Comment actions Permalink
  • Rainer Grabowski

    This notitification often means, that a quotation mark is missing or that you've a typo.Please copy & paste your code here.

    0
    Comment actions Permalink
  • Troy Muir

    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 :(

    0
    Comment actions Permalink
  • Rainer Grabowski

    Sorry, but for me it works (s. image). Are there other lines in the calculation field?
    Image

    1
    Comment actions Permalink
  • Troy Muir

    Thanks Rainer - Nope, i only have in there what you've given me. I've even tried a different phone field name - but i still get the same error. How strange :(

    0
    Comment actions Permalink
  • Rainer Grabowski

    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.

    0
    Comment actions Permalink
  • Troy Muir

    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.

    -1
    Comment actions Permalink
  • Charl Henning

    Troy

    Calculation fields have a memory from when they are first created. If you started off using text, you cannot go back and change the data to calculations and numbers, or vice versa. You need to delete the block and create a fresh one. 

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk