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
Adhvika BalaAdhvika Bala 

If Case Status is selected as "In progress" then make case comment mandatory

IF Case Status is selected as "In Progress" then Users has to enter Case Comment(make case comment mandatory).
Do we need to write  a trigger for this or can this done with out of the box options. Please advise!!
VinayVinay (Salesforce Developers) 
You can simply write a validation rule
AND(ISPICKVAL(CaseStatus,'In progress'), ISBLANK(Case Comment))

Hope this helps...

Thanks,
Adhvika BalaAdhvika Bala
How do we access Case Comment from Case .
Tested out a validation rule.
Case comment is not available in Insert Field list in validation rules.

Thanks!
VinayVinay (Salesforce Developers) 
Unfortunately, You cannot use case comment field on validation.

Check below Idea link and vote

https://trailblazer.salesforce.com/ideaView?id=08730000000LjWrAAK

Workaround would be, create custom field and use custom field as case comment and write a validation rule on case comment custom fields.

Thanks,
Adhvika BalaAdhvika Bala
Is there a way we can do this with Flow. If so any idea on how this can be done please.
 
VinayVinay (Salesforce Developers) 
I don't think you can achieve this by using flow.  Validation rule and trigger should do this.

Please mark as Best Answer if above information was helpful.

Thanks,
Abdul KhatriAbdul Khatri
Hi Adhvika,

Please try this

Since Commnents is a Text Area (4000), so it will not be available
1. In Validation Rules
2. In Formula Fields

Therefore you best bet here is trigger as below.
trigger CaseCommentMandatoryTrigger on Case (before insert, before update) {
    
    for(Case caseRec : Trigger.new)
    {
        if(caseRec.status == 'In progress' && String.isBlank(caseRec.Comments))
            caseRec.addError('Please enter the comments');
    }

}

Let me know if this help