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.

Examples

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

title#4,-4=^title^
result: dent

Pull the 5th character

title#1,4=^title^
result: i

Pull the last character

title#1,-1=^title^
result: t

Remove last 5 characters

title#-5,0=^title^
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:

telephonenumber=5554563239
sn=Smith
givenname=Jane

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:

extensionAttribute1=Jane.Smith-3239
homephone=(555) 456-3239

Example 2

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

whenCreated:20141210135109.0Z

And we map:

extensionAttribute1=&'^whencreated^'.slice(0,4)&:&'^whencreated^'.slice(4,6)&:&'^whencreated^'.slice(6,8)&T&'^whencreated^'.slice(8,10)&:&'^whencreated^'.slice(10,12)&:&'^whencreated^'.slice(12,14)&

The Synced value will be:

extensionAttribute1=2014:12:10T13:51:09


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:
Knowledgebase

Directory
  1. Directify - Self Service

  2. Mimic - Replication

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