Custom Mapping: Javascript Mapping

Created: 2017-02-15 13:10:05
Modified: 2022-03-20 13:37:15
Tags: Custom Mapping Javascript UnitySync

Attribute mapping can be enhanced by the use of 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


More Sample mappings:

Convert a string (number) to a an integer so you can set an integer only dest attribute (i.e. enabledprotocols).

enabledprotocols=&parseInt(“^department^”)&

Set destination conditionally based on source attribute value).

company=&‘^company^’ == ‘’ \? ‘None Specified’ : ‘^company^’&


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

Knowledgebase

Directory
  1. Directify - Self Service

  2. Mimic - Replication

  3. UnitySync - Sync
Password
  1. emPass - Sync
Obsolete
  1. Profiler
  2. SimpleSync