Happy Business Starts Here

Zuora Support

How to set a field to NULL via SOAP API

Problem

 

User needs to set a field that has an existing value to NULL using update() call via SOAP API.  For example, an account has Notes = 'Account has been suspended.' and now the note needs to be removed.  User creates an update() Account call.

 

<ns1:update>
    <ns1:zObjects xsi:type="ns2:Account">
        <ns2:Id>2c92a0fe56b17c5f0156beb8fdf826fc</ns2:Id>
        <ns2:Notes></ns2:Notes>
    </ns1:zObjects>
</ns1:update>

 

However, when checking the Notes field, the value 'Account has been suspended.' is still there.

 



If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

1 REPLY 1
Zuora Support

Re: How to set a field to NULL via SOAP API

Solution

 

The correct way to set a field to NULL is to use fieldsToNull option.  The SOAP call should be

 

<ns1:update>
    <ns1:zObjects xsi:type="ns2:Account">
        <ns2:fieldsToNull>Notes</ns2:fieldsToNull>
        <ns2:Id>2c92a0fe56b17c5f0156beb8fdf826fc</ns2:Id>
    </ns1:zObjects>
</ns1:update>

 

  • fieldsToNull - pass the Name of the field (e.g., Notes) which needs to be NULL
  • Id - Id of the account

Please note that the order of the fields is important so fieldsToNull must be placed above Id.

 

Reference

 



If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √