Synchronization Editor, Native Database Connector, SQL-Server provisioning NULL values

Hi,

How can I synchronize a NULL value to a  MS SQL DB. (varchar null allowed)

1IM replaces Null values with each FullExport with "string Empty" value.

Thanks for any hint

Olivier

Parents Reply Children
  • You are right that even the script property doesn't help. It seems that the problem can't be solved with the mapping. One option would be to define script based data operations. These can be found when the target system connection is edited on the page "define data operations".

    Other workaround: Adding a condition to the mapping rule (disabling mapping rule if value is null on your side) - this might cause issues when you're updating data from "something" to NULL.

  • Thank you for the answer

    i have already a condition to the mapping rule in place, so i have only the case updating from "something" to NULL.

    I will now try with the script based data operation, thanks for that hint!

  • I could fix it with this script based data operation:

    Dim store As IValueStore = data.Values.CreateValueStore()
    Dim sVisum as String = data.SystemObject.getValue("sAMAccountname","").ToString
    Dim sPersonalTitleGerman as String = store.getValue("personalTitleGerman","")

    ' Check if Attribute was changed. The IValueStore contains only the changed columns.
    ' Use data.SystemObject.GetValue to fetch values from unchanged columns of the object

    If store.Contains("personalTitleGerman") Then
    If String.IsNullOrEmpty(sPersonalTitleGerman) Then
    connection.ExecuteSqlNonQuery(store.Replace(String.Format("UPDATE Tel_Daten SET personalTitleGerman = NULL WHERE sAMAccountname = '{0}'",sVisum), True))
    Else
    connection.ExecuteSqlNonQuery(store.Replace(String.Format("UPDATE Tel_Daten SET personalTitleGerman = '" & sPersonalTitleGerman & "' WHERE sAMAccountname = '{0}'",sVisum), True))
    End If
    End If

  • Thanks for sharing your solution. Much appreciated.

  • You should reconsider the way your queries are build. Your example is vulnerable to sql injection.
    Currently provisioning a value like "foo'--" as personalTitleGerman will result in all entries in Tel_Daten being updated to personalTitleGerman = foo.