Introduction:

Custom field formats

We recently introduced new custom field options when working with phone numbers.

{mobile|national} is the default. Its the phone number minus the + symbol and minus the international code

{mobile|international} is used when you need the number with + symbol and with the international code.

Scripted format

For some of our users both of the formats above will be rejected by CRM’s.

In this case whats usually required is the digits with no spaces, no brackets, and no hyphens.

The following script does this:

<script>
  var number = '{mobile}';
  
  //Print the initial value on the browser console
  console.log(number);
  
  //Remove white spaces
  number = number.replace(/\s/g,'');
  
  //Remove brackets
  number = number.replace(/[()]/g, '');
  
  //Remove hyphens
  number = number.replace(/-/g, '');
  
  //Set custom field {variable} with the new number
  DT.setField('variable', number);
  
</script>

Note: You would need to first save the phone number in the {mobile} custom field. So setup a node to capture the phone number

You also need to create a text custom field called {variable}. This will be the new phone number.

Finally you need this script to fire on exit of the node where you ask for the number. That’s because we need the user to enter his phone number first before scrubbing his number with the script.