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
Raju Sen 21Raju Sen 21 

Apex Trigger to Update Case Status on Update of Task Status


I want to update case and prevent case status updation on update of Task. Task has 5 recordtypes which are FC, Repo, ST, Auction and Legal Assessment and these record types have different statuses for completion of Task which are Resolved, Repo, Located, Proceed and Complete respectively.
So whenever I complete a task, case statuses changes to Intermediate Review, Intermediate Review, Intermediate Review, Intermediate Review and Final Review respectively (depending on the Completion status of Task of that particular Task recordType).

Here is the requirement I am facing difficulty with: If a Case has a Status of ‘Legal Assessment’ and an incomplete Task of 'Legal Assessment', then completion of another incomplete Task will not override the Case Status

Can anyone help me with a logic here?
akschampakschamp
Hi Raju,

when you are updating Case status, you need to check the current case status (Legal Assesment) and then query all tasks related to that case with status Legal Assesment, if you get more then one record then do not proceed with Case status update.