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
Luke Vang 48Luke Vang 48 

Unable to delete JS object property

Hey,

I'm trying to delete property on one of my objects, but I"m seein this error:

Cannot delete property 'Field Name' of #<Object>

I've already verified the field is on the object, so I know the error isn't due to it missing or anything. But guessing because of the new secure objects we arn't able to call a delete on the object to remove the property?

Here's an example of what I'm trying to do:
if(object[fieldx]){
    console.log(object);
    delete object[fieldx];  
   }


 
SFDC Coder 1SFDC Coder 1
Hi Luke Vang 48,

Instead of deleting the property from the object. Assign the value of the property as 'Undefined' and check if it fits in your business requirement.

let know if this helps you in finding your Answer then mark it as Best Answer.