function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael DsozaMichael Dsoza 

Update few fields with value but rest of the fields with NULL value


I have one custom object records where every field is updated with value and I want to update this record with few fields but rest of fields should be updated with NULL value. 

Since custom object is having more than 100 fields so that I can not set null value into the fields manually. So please guide me how can I achieve this...

Hi Michael,

Please set only the required fields of object, rest of fields will updated with null or with thier defaut values.

Please let me know if I can help you more.

Michael DsozaMichael Dsoza
Hi Vishal,

Thanks for your reply.

Since all fields of the records are filled with value and I want to update the few fields but how can rest of the fields will set to null. untill and unless I specify to null while updating records ??

Also, I dont want to set 100 of fields to null while updating records so is their alternative approach to do this in apex ??
In SOAP/REST API, we have an option to set FieldsToNull option in an object but that is not allowed in apex code.

Please let em know if any queries and help me to resolve this.