Custom Mapping: String Manipulation

Created: 2012-04-20 08:09:59
Modified: 2019-08-15 16:41:05
Tags: Custom Mapping UnitySync

String manipulation is used within custom map files to truncate or extract characters from a string. If you have a unique format for an attribute we suggest you create a custom map file and use the examples below as a guide to producing desired results. Of course, you are always welcome to contact our Technical Support Team for assistance.

The basic syntax for string extraction is:

[dest attribute]#[Num of characters],[Offset]=^some source attrib^

Please note, [Num of characters] refers to how many characters you would like to extract from the string, and may be specified alone. [Offset] refers to where in the string to begin pulling from. Zero or no value means to start at the left most character. A positive value means so many characters from the left. A negative value means so many characters from the right. When using [Offset], [Num of Characters] is required.


In this case we will manipulate the title attribute. The source value for this attribute is president.

Pull 4 characters from the left

title#4=^title^ or title#4,0=^title^
result: pres

Pull 4 characters from the right

result: dent

Pull the 5th character

result: i

Pull the last character

result: t

Remove last 5 characters

result: pres

The above examples will work on all versions of UnitySync.

If you want to build a value from multiple source attribute values, however, you may use scripting in combination with string manipulation. A mapped value may be constructed from multiple source fields or with a combination of fixed values. For example, if you want the first letter of given name, period, full last name, dash, last 4 digits of phone number…

IMPORTANT NOTE: In UnitySync v2.4 and later use javascript in combination with string manipulation. In versions earlier than v2.4, we urge you to upgrade to the latest version.

Example 1

In this example, we will concatenate and trim data. Our Source data includes:


If we map:

extensionattribute1=^givenname#1^.^sn^ -&'^telephonenumber^'.slice(-4);&

`homephone=(^telephonenumber#3^) &'^telephonenumber^'.slice(3,6);&-&'^phtelephonenumberne^'.slice(6,10);&

The Synced values will be:

homephone=(555) 456-3239

Example 2

In this example, we will reformat the date. Our Source data is:


And we map:


The Synced value will be:


Please see the Javascript category in our knowledge base for more information on scripting. For additional assistance with these types of mappings, please contact our Technical Support Team.

Share this article:

  1. Directify - Self Service

  2. Mimic - Replication

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