Formatting and OnSaving script returns an error in Synchronization Log

We are synchronizing a property from the target system to One Identity database. The issue poped up, when we deleted an object in One identity database to check if the Formatting script works properly.

However the synchronization log returned an error.

We tested this script in 4 different ways:

1. The template on the field ramained untouched, we inserted the bellow code in the Formatting script of the field.

2. The template on the field ramained untouched, we inserted the bellow code in the OnSaving script of the table.

3. The template on the field was removed, we inserted the bellow code in the Formatting script of the field.

4. The template on the field was removed, we inserted the bellow code in the OnSaving script of the table.

If String.Equals($FK(UID_LDPDomain).Ident_Domain$, Connection.GetConfigParm("Custom\LDAP\LDAPDomain")) OrElse _
    (String.Equals($FK(UID_LDPDomain).Ident_Domain$, Connection.GetConfigParm("Custom\LDAP2\LDAPDomain")) AndAlso String.Equals($StructuralObjectClass$, "HIERARCHY", StringComparison.OrdinalIgnoreCase)) _
    Then
    If String.IsNullOrWhiteSpace(Cstr(Value)) Then
        Throw New ViException("The UniqueKey is required, value can not be empty.", ExceptionRelevance.EndUser)
    End If
End If

What could be the reason that the code is trigerred in either the Formatting script and in the OnSaving script if the value is inserted through the synchronization project?
The template is not triggered becouse of the condition: "If Not CBool(Variables("FULLSYNC")) Then", which means that the value is set through synchronization project property mapping.
If we remove the code from either the Formatting script and in the OnSaving script, the value is inserted as expected.

  • We found a solution to this as we tested all sorts of things further down the way.

    The problem is that during synchronization, UID_LDPDomain is filled on the object before the value is received from the Synchronization from target system and becouse UID_LDPDomain is also a trigger for the template and Formatting script, both are executing before the value even exists in the database.

    We solved this in the If statement and now the Formatting script looks like this:

    If String.IsNullOrWhiteSpace(Cstr(Value)) AndAlso $UID_LDPDomain[c]:Bool$ = False Then
    	If String.Equals($FK(UID_LDPDomain).Ident_Domain$, Connection.GetConfigParm("Custom\LDAP\LDAPDomain")) OrElse _
    	    (String.Equals($FK(UID_LDPDomain).Ident_Domain$, Connection.GetConfigParm("Custom\LDAP2\LDAPDomain")) AndAlso String.Equals($StructuralObjectClass$, "HIERARCHY", StringComparison.OrdinalIgnoreCase)) _
    	    Then
    	    If Not String.IsNullOrWhiteSpace($UID_LDPDomain$) Then
    	        Throw New ViException("The UniqueKey is required, value can not be empty.", ExceptionRelevance.EndUser)
    	    End If
    	End If
    End if