If-Then-Else logic in custom mapping2018-12-05 14:15:46
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^'&
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"))&
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