4

I'm trying out the new WSProxy API for server-side javascript. I haven't been able to update a Data Extension field to NULL when it already contains a value.

Let's say "Student" is a nullable field. Putting this into the Properties array passed to the updateItem method doesn't clear out a value already stored in the Data Extension:

{
    Name: 'Student',
    Value: null
}

Neither does leaving the Value property out entirely:

{
    Name: 'Student'
}

The SOAP API documentation makes reference to a NullAPIProperty object to use in this circumstance, but I can't figure out how to pass that kind of object to WSProxy or get that API to create it. (Creating an object using Platform.Function.CreateObject() throws an error; that's a different API).

4
  • have you tried Value: ''? Commented Jun 21, 2018 at 13:40
  • I verified that '' as a Value works for boolean fields! Text fields are set to a zero-length string, which is not the same as NULL. This is important when using the IS NULL operator and similar functions in SQL.
    – Billk
    Commented Jun 21, 2018 at 21:58
  • try { Name: 'Student', Value: } - but I expect you will likely get a syntax error. I think the empty string may be the best you can do. Perhaps try putting in a support ticket to SFMC. I will explore on my side as well and post if I find an answer Commented Jun 22, 2018 at 12:37
  • OH! Try setting a SSJS var to null then put that var inside your WSProxy call. var iAmNull or var iAmNull = null then { Value: iAmNull } I get the feeling this may not work either, but worth exploring. Commented Jun 22, 2018 at 12:38

1 Answer 1

11

There's a hidden feature of WSProxy to allow you to do this!

If you were to write the raw SOAP call to set the value of a field in your DE record to NULL, you'd write it like this:

       <Property xsi:type="NullAPIProperty">
          <Name>StoreNumber</Name>
       </Property>

Notice, there's no value, but there is a type attribute on the Property element. You have to set that NullAPIProperty attribute on your property in the WSProxy call. To do that, you use a special notation: __Type__

So, you'd write your null property like so:

{
    Name: 'Student',
    "__Type__": 'NullAPIProperty'
}

The attribute notation is unfortunately not currently documented, but I'll see if I can contact someone who can get it on the help site.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .