Monday, April 29, 2019

Set sublist value to null with web services

When adding new records with Web Services sublists with default values can't be set to null as the nullFieldList as it only applies to body fields.  A way to do this is with a custom field and scripting.  The below example is for adding customer records and setting the country field on the address sublist to null.

1. Create a new custom field on the record type which needs to have fields that get set to null.  Set type to Free-Form-Text and uncheck Store Value.  Name it something descripting (Eg "Clear Countries for Addresses") and take note of the field id after saving.

2. Create a new User Event Script and set this to be the code.  The function should be called Before Submit and the script should be deployed on the same record type as the field from step 1.  Replace custentity1 with the field id from step 1.  Change the sublsit ("addressbook" in this example) and the field ("country" in this example) to be the sublist id and field id for the field that needs to be set as null.

3. When making web services requests specify the sublist lines that need to have the field set to null separated by commas in the field from step 1.  Eg set custentity1 to "1,2,3" so that address lines 1, 2 and 3 don't have countries.

No comments:

Post a Comment