Synchronization editor problem: mapping property with script retrieve object

Hi all,

I'm synchronizing a csv with the department objects

in my csv file I had a code for department manager that is equal to a code in field CustomProperty01 on Person object.

With the property "Key resolution by reference" I can insert the UID_Person in UID_PersonHead on Department object but...

If Person has a UID_PersonMasterIdentity is not empty I need to insert in UID_PersonHead of Department that UID.

So if a Person as a masteridentity attached to it I need to insert that person as department Manager.

I don't know how to do it in Synch Editor I thinkg with a script property but I can't figure out how.

 

Thanks 

Mik

  • Just for clarification. You are mapping the content of the CSV file to the Department table in the Synchronization Editor, correct?

    You have a virtual property of type - key resolution by reference - to map the department manager code from the CSV to Department.UID_PersonHead and you are searching the Person via CustomProperty01, correct?

    Now, if the Person found via CustomProperty01 has a UID_PersonMasterIdentity assigned, you need to use that UID to fill Department.UID_PersonHead, correct?
  • Hi Michele,

    as you have assumed, you need to define a Script property to achieve your goal.

    In the script you have access to the properties of the current object, the current value when the sync engine tries to set a property and you can query for other objects the connector has access to, defined by your current schema definition (we come to that in a second).

    The sync engine itself, and therefore the scripted property has no direct access to the OneIM database, the object layer or the script library.

    Having explained that, here is your solution:

    • You need to define script property on the OneIM (the left) side of the mapping in the Department objects. In my sample, it is called vrtPersonHead. 
    • As in your use-case definition, we only need a write script.
    • Script code is the following:
    Imports VI.Projector.Connection

    Dim Person As ISystemObject = SystemObject.Connection.QueryObject(SystemQuery _
    .From("Person") _
    .Select("UID_PersonHead", "UID_PersonMasterIdentity") _
    .Filter(String.Format("CustomProperty01='{0}'", value.ToString))
    ).Result.FirstOrDefault

    If Not Person Is Nothing Then
    If String.IsNullOrEmpty(Person.GetValue("UID_PersonMasterIdentity").AsString) Then
    $UID_PersonHead$ := Person.GetValue("UID_PersonHead").AsString
    Else
    $UID_PersonHead$ := Person.GetValue("UID_PersonMasterIdentity").AsString
    End If
    End If
    • You need a mapping from your CSV column that stores the Manager lookup value to the new script property. In my sample, this is the mapping column CustomProperty01 in my CSV file to the script property vrtPersonHead.

    • You need to pin the Person objects in your schema, as the connector is only able to access objects that are part of your sync project schema. So when you shrink the schema, you need to exclude the Person table from the shrink, when it isn't a part of your sync project already.

    The script demonstrates the use of:

    • How to query data from other objects that are part of your sync project.
    • How to set another property in your object (:= notation) in a write script
    • How to us the current value in a write script.

    Hope that helps.

  • Where I can find the documentation for ISystemObject and SystemObject.Connection.QueryObject?