DirWiz Logo
Knowledgebase

Article Tags

Javascript single line mapping examples

2018-12-05 14:27:37
Custom Mapping Javascript UnitySync 

To insert +44 if the source value does not start with a + character:

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

Return value and format
Emp123403102018

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

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: LinkedIn Twitter reddit