If Then Else logic in custom mapping

Created: 2012-04-20 08:09:59
Modified: 2021-10-25 11:42:40
Tags: 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:
Knowledgebase

Directory
  1. Directify - Self Service

  2. Mimic - Replication

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