Skip to main content

Help with Pre-Map script

Answered

Comments

2 comments

  • Official comment
    Matt Graney Chief Product Officer
    Engaged
    Answer Pro
    Top Contributor

    Hi Brian,

    This is Matt, head of Product at Celigo.

    The following code iterates over each record in the data[] array and simply concatenates the pieces of the number with the additional characters. Hope this helps.

    -Matt

    Try this:

     

    function convertPhoneNumber (options) {
      options.data.forEach(function(i) {
      let tmp = i["Store Phone Number"]
    i.cleanNumber = "(" + tmp.substring(0,3) + ") " + tmp.substring(3,6) + "-" + tmp.substring(6,10)
    })
    return {
    data: options.data,
    errors: options.errors
    }
    }

    The following sample:
    {
    "errors": [],
    "data": [
    {
    "Store Phone Number": "3334445555"
    },
    {
    "Store Phone Number": "1234567890"
    }
    ]
    }

    Yields:
    {
    "data": [
    {
    "Store Phone Number": "3334445555",
    "cleanNumber": "(333) 444-5555"
    },
    {
    "Store Phone Number": "1234567890",
    "cleanNumber": "(123) 456-7890"
    }
    ],
    "errors": []
    }


  • Brian Duffy Salesforce Integration Whiz NetSuite Integration Whiz
    Celigo University Level 4: Legendary
    Engaged

    Hi Matt,

    Thank you for your help.

     

    Brian

    0

Please sign in to leave a comment.