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
Pugalagiri JPugalagiri J 

System.sObjectException field <fieldname> is not editable

Trying to create sObject but getting error as below for certain fields

Error: System.sObjectException field <fieldname> is not editable

Code Snapshot:
Code in Account Change Event trigger (change data capture), with this code trying to convert Trigger.New to sObject

for (sObject event : Trigger.new)
{
Map<String, Object> fieldvalues = event.getPopulatedFieldAsMap();
sObject sObj = Schema.GetGlobalDescribe().get('Account').newSobject();
for(string FieldKey : fieldvalues.Keyset())
{
      sObj.put(FieldKey,fieldvalues.get(FieldKey));
}
}

Any help?
ravi soniravi soni
hi Pugalagiri,
I might be your field is formula Or Edit permission is not given that user.
so, you can check profile of that user.
Or
In Object, go to the field & Relationship and search the field name and make sure that field is formula or not.
follow above steps and let me know if it helps you and if it helps you, marking it as best answer.
Thank You
Pugalagiri JPugalagiri J
Field I am referring is picklist field and its editable for my login.

Specific code will be executed by Process Automated user (asynchronous) since its been triggered from change event trigger (change data capture).

Basically I am trying to transform Trigger.New in to Sobject specific to the object type.
Pugalagiri JPugalagiri J
Did further troubleshooting and fetched list of fields failed with reported error.
All failed fields are either Formula field or RollupSummary field, looks like this is the reason for the reported failure