DirWiz Logo
Knowledgebase

Article Tags

Custom Mapping: Javascript Mapping

2019-08-15 16:41:20
Custom Mapping Javascript UnitySync 

Attribute mapping can be enhanced by the use off Javascript. This includes scripting within your custom map files as well as via eval.js subroutines.

Below find examples of commonly used javascript mappings.

To insert country code to a telephone number

The below mapping will insert a country calling code if the Source data is missing it. In this example, we are using +44 for the UK.

NewPhone=&"^telephonenumber^".substr(0, 1) == '+' \? '^telephonenumber^' : '+44 ^telephonenumber^'&


Slice source data for specific format

The below mapping will:

  • Insert prefix ‘Emp’
  • Grab the final 4 characters of Empnr
  • Drop the / from HireDate
  • Returns result as one string

Source data:

Empnr=001234
HireDate=03/10/2018

Mapping:

extensionAttribute3=Emp&"^Empnr^".slice(-4)&&"^HireDate^".replace(/\//g,'')&

Return value and format:

Emp123403102018


For more complex javascript commands, refer to Sample Javascript Functions. Using eval.js with custom mappings allows for more complex data manipulation.

Share this article: Twitter reddit