Jump to content

Need help modifying "Format phone" rule


MikeVM

Recommended Posts

Hi,

 

We always use standard rule for “Format phone”. Looks like one of our client need some improvement - they need to be able to put an asterisk right before extension:

they want to get their phone like this: 123-456-7890 ext. *456

or like this: 123-456-7890 ext. 456

 

Unfortunately standard rule does not allow to put an asterisk along with digits of extensions…

 

any help?

 

Thank you

Link to comment
Share on other sites

Open the "change phone format rule" and convert it to javascipt.

once that is done, you can select the section - in this case section 1 - and replace it with

if(CaseSelection == "Format 1")
{
var formatStyle02 = "$1-$2-$3";            //simple 10 digit phone
var formatStyle04 = "$1-$2-$3 ext. *$4";        //10 digit phone with '*' before extension
var formatStyle07 = "";    
var thisNumber = Field(Var1);
return formatNumber(Trim(thisNumber));
}    

You could also delete the sections you are not using, but don't delete the information below the hash lines.

Link to comment
Share on other sites

LesSjo,

 

thank you, but your code only add (*) before extension, and does not allow to enter extension number without it. As I mention in my first post, my clients should be able to enter extension with or without asterisk...

Link to comment
Share on other sites

try something like this. It may not be pretty, but it will work with some manipulation.

 

Include a user dropdown list to have the values of "phone with asterisk before extension" and "phone with extension only" or something similar. Depending on which value the user selects, return either the first format or the second format.

 

if(CaseSelection == "asterisk_ext")
{
var formatStyle02 = "$1-$2-$3";            //simple 10 digit phone
var formatStyle04 = "$1-$2-$3 ext. *$4";        //10 digit phone with '*' before extension
var formatStyle07 = "";    
var thisNumber = Field(Var1);
return formatNumber(Trim(thisNumber));
}

if(CaseSelection == "ext")
{
var formatStyle02 = "$1-$2-$3";            //simple 10 digit phone
var formatStyle04 = "$1-$2-$3 ext. $4";        //10 digit phone with '*' before extension
var formatStyle07 = "";    
var thisNumber = Field(Var1);
return formatNumber(Trim(thisNumber));
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...