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
Christopher Peck 16Christopher Peck 16 

How to update a case field in Apex

This should be simple and have found multiple examples but my situation is simply this, I want to update a Case field in Apex. There are actually two fields:

Disposition__c (picklist)
PC_Parent__c (Boolean)

parentCaseId is a variant is successfully passed. I have tried many examples found including the article:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_examples_insert_update.htm

every time I try a queryresult.Disposition__c, for example, I get the error when saving:

Error: Compile Error: Variable does not exist: Disposition__c at line xx column xx

An example of the full part of Apex is:

Id u = (Id)childCase.getField('Id');
    childCase = AccessControl.encapsulate([
    SELECT CaseNumber, ParentId, AccountId, ContactId, Disposition__c
    FROM Case
    WHERE Id = :u
    ]);
            
    childCase.Disposition__c = disposition;
            
    update childCase;
Anthony McDougaldAnthony McDougald
Hello Developer,
Hope that your day is off to an amazing start. Please edit the following line of code with the succeding and let us know how it turns out. Have a blessed day.
childCase.Disposition__c = disposition;
childCase.Disposition__c = 'disposition'; (Change the above to this)
Best Regards,
Anthony McDougald