- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2014 02:01 PM
Hi there!
Nice to meet your acquaintance. I am running into a problem where I have an excel spreadsheet that has numbers formatted like this "8107463849" on the Excel spreadsheet, but I need them to be imported into a String field as "(810) 746-3849" without the quotes, and with a space between the ) and the 7.
I have been trying to come up with a way to do it, but I can't seem to get anything to work. I was trying to run it Onstart, as a New Transform Map Script (not the first one you see on the Transform Map form). I also looked into researching setting up the Phone Number in the System Properties and setting it to True with the glide UI, but the instance I am working with does not want this global. They want it only for this specific field.
This is also in Dublin.
Does anyone have something that does this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2014 01:51 PM
It is adaptable to a transform:
target.u_phone = formatPhone(source.u_phone);
function formatPhone(str) {
var area_code = str.slice(0,3);
var first_three = str.slice(3,6);
var last_four = str.slice(6,10);
var ph = "(" + area_code + ")" + first_three + "-" + last_four;
return ph;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2015 02:17 PM
It depends on how you want to handle non-phone numbers in the phone field. For us a blank phone number is okay.
To identify letters and strip out you can use a regex that identifies non-digits, and the replace method to remove them:
var phone_with_letters = 'A919EA-Gh5h5y5-013Zz4';
var phone_without_letters = phone_with_letters.replace(/\D+/g, '');
alert(phone_without_letters);//alerts 9195550134