# Help with Pre-Map script

**URL:** <https://connective.celigo.com/t/help-with-pre-map-script/1445>\
**Category:** Integrator.io\
**Tags:** script, netsuite\
**Created:** [April 1, 2019, 7:48pm UTC](https://connective.celigo.com/t/help-with-pre-map-script/1445 "2019-04-01T19:48:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianduffy](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@brianduffy](https://connective.celigo.com/u/brianduffy)\
**Post date:** [April 1, 2019, 7:48pm UTC](https://connective.celigo.com/t/help-with-pre-map-script/1445/1 "2019-04-01T19:48:27Z")

</div>

I need to convert phone number from a string, ie 3334445555 into a formatted number, (333) 444-5555 in order to match customer in NetSuite.

My input data is:

"data": [

{

...

"Store Phone Number": "3334445555",

....

}

]

I don't understand how to pull out the phone number, alter and then pass it.

Has anyone done this? Help is much appreciated.

Brian

---

<div class="post-metadata">

**Author:** ![mattgraney](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/mattgraney/32/6606_2.png) [@mattgraney](https://connective.celigo.com/u/mattgraney)\
**Post date:** [April 5, 2019, 6:09pm UTC](https://connective.celigo.com/t/help-with-pre-map-script/1445/2 "2019-04-05T18:09:36Z")

</div>

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": []}
```

---

<div class="post-metadata">

**Author:** ![brianduffy](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@brianduffy](https://connective.celigo.com/u/brianduffy)\
**Post date:** [April 8, 2019, 2:16pm UTC](https://connective.celigo.com/t/help-with-pre-map-script/1445/3 "2019-04-08T14:16:53Z")

</div>

Hi Matt,

Thank you for your help.

Brian
