DirWiz Logo
Knowledgebase

Article Tags

If-Then-Else logic in custom mapping

2018-12-05 14:15:46
Custom Mapping Javascript Troubleshooting UnitySync 

If-Then-Else logic in custom mapping

There is some If-Then-Else logic (scripting) we can incorporate into a UnitySync map file for additional flexibility in syncing attribute data.

For example, perhaps you do not want the company attribute to be blank on your Destination but at least some of your Source objects do have blank company attributes. You want your mapping to accomplish the following:

IF ^company^ is blank, THEN set Company to ‘None Specified’ ELSE set Company to the actual value of ^company^

The mapping, then, looks like this (in UnitySync v2.4 and later):
company=&'^company^' == '' \? 'None Specified' : '^company^'&

In earlier versions of UnitySync, Perl was used rather than Javascript. If your version is older and you wish to utilize If-Then-Else logic, please first upgrade to the latest version of Unitysync.

More complex if/then/else routines are possible, but cumbersome.

company=&"^company^" == "1001" \? "^company^ - corporate":("^company^" == "1002" \? "^physicaldeliveryofficename^ - local":("^company^" == "9999" \? "^c^ - international":"^company^ - unknown"))&

Note:

If the routine gets much more complicated, it’s likely easier to use a custom \global\eval.js
Refer to the IfThenElseReturn subroutine.

For more one line examples, Refer to Single Line mapping examples

Share this article: Twitter reddit