0

I need to make logic, that i can not save Case as solved as long, as there are actvie subcases (child cases).

So I need to check somehow, if child cases are in status, for example 4, and than allow to finish parent Case.

If child cases are all not in status, i need to show error message about "there are opened subcases, you cannot finish this case".

I have a basic method to close case here

public PageReference terminate() {
    PageReference result = validateAndResolveToStatus('7');
    // send notification to parent's owner if it's a user on successful save
    if (result != null) {   // save OK
        Case c = (Case) controller.getRecord();
        if (c.ParentId != null) {
            String parentOwnerId = c.Parent.OwnerId;
            if (parentOwnerId.startsWith('005')) {
                sendNotificationToUser(parentOwnerId, 'KLIP_03_ChildCaseSolved_ToParentOwner', c.Id);
            }
        }
    }
    return result;
}

And there is a button

<apex:commandButton value="Resolved" action="{!terminate}"/>

Thank you for any help

1

In your method you need to check all child cases if they all are completed or not.

List<Case> childCaseList = [SELECT ID from Case WHERE ParentID =: c.Id and and Status != '4'];
if(childCaseList.size() > 0) {
    //list size is >0 means you have open child case so you can't close parent case
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.