From SeedCode Documentation

GoZync3: SetFieldTransformations

These are the notes for GoZync 3. Docs for the latest version of GoZync--GoZync 4--can be found here. GoZync 4 is a free upgrade and is highly recommended (hint: it's faster).

Getting in between GoZync and your data: changing our SetField script


The fields on your mobile and hosted files may be different. They may have different names, or need to contain different data.

If the only thing you need to deal with is that your fields have different names, you can handle that in the custom field mapping section of GoZync's integration.

If, however, you need to change the data from one side to the other (like merging first and last names into a full name, or changing date formats) the instructions below are for you.

Editing our Set Field Scripts.

You'll find a script called "Set Fields" in both GoZyncHosted and GoZyncMobile. This is the script that actually moves the data from our synced "package" into your fields. This is done with a single SetFieldByName script step shown in blue below.

In order to transform the contents of a field during the sync, you'll replace this line with a few IF statements and calcs. The final result is shown below. After the screen shot we'll walk you through making this change.

The first thing to do is copy the calc part of that SetFieldByName step (the long let statement that gets the field value) and set that to a variable called $fieldValue. You'll see that as the first line in blue in the screen shot above.

Then create an If statement for each field you'd like to transform, testing the field name. Remember this is the field name in the mobile / hosted side you're working on. So if you're editing this script in GoZyncMobile, you're looking for the name of your Mobile field.

And the field name here is the full field name, like this:


Rather than putting the name in quotes as in our screen shot, wrap it in the GetFieldName() function like this...

$fieldname = GetFieldName ( Contacts::LastName ) that will protect you if you ever change the way "LastName" is spelled in field definitions.

Add an ElseIf for each field name you want to manipulate, and then end with an Else setting the $fieldname to the untransformed $fieldValue. When you're transforming, remember that $fieldValue will sometimes be blank, so you might use a calc like this if you were transforming dates:

Let ( [

t = $fieldValue ; sp = Substitute ( t ; "/" ; "" )

] ;

if ( isempty ( t ) ; "" ; Date ( GetValue ( sp ; 2 ) ; GetValue ( sp ; 1 ) ; GetValue ( sp ; 3 ) ) )


You can do this in the SetField script in both GoZyncMobile and GoZyncHosted.


Retrieved from
Page last modified on August 05, 2013, at 04:23 AM