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
Praveen JhaPraveen Jha 

Change case status from new to working when any comment is added to the case through trigger-Very Very Urgent

Change case status from new to working when any comment is added to the case through trigger. Users can not update the case through SF UI.
Best Answer chosen by Praveen Jha
PratikPratik (Salesforce Developers) 
Hi Praveen,

So all you need to bypass the validation rule when your case comment is added.

Follow these steps:

1. Create a Checkbox say Validationflag
2. Set it default as Unchecked.
3. Change you validation to add :

CONTAINS($Profile.Name, "Basic") && 
 ISCHANGED(Status) && 
NOT(ISNEW()) && (​Validationflag__c==false)


4. In your workflow on Cas comment add one more field update to Update the Checkbox on Case Validationflag = true.

5. Create a workflow rule on Case
Rule criteria: Case status= Working
Add Field update 
Validationflag =False.
This will ensure that Status can be changed only through Case comment.

This will work.

Thanks,
Pratik

P.S. If this answers you question, please mark it as "Best Answer" so it will help other community members too.
 

All Answers

PratikPratik (Salesforce Developers) 
Hi Praveen,

Can you elaborate on how you are adding the case comments from trigger, please post the code.

To change the Case status:

You can create a Workflow rule on Case comment on Evaluation Criteria  "created" and set rule criteria as case comment body not blank. Add a Field update action and set Case status= Working.

This works fine, as soon as you add case comment, your case status will change to Working.

If case comment is getting added through trigger and if there is a perticular member name in "case comment created by" for every case comment, then  add that rule criteria in workflow.

Thanks,
Pratik
 
Praveen JhaPraveen Jha
It's my apologies we can achieve this requirement either trigger or workflow
 
Praveen JhaPraveen Jha
Thanks Pratik, I have already did this, but it's not working.
 
PratikPratik (Salesforce Developers) 
Hi Praveen, Will you please describe In which scenario its not working, i tried and its working even though you add case comment through trigger. Also check for any conflicting workflows or triggers in your instance. Thanks, Pratik
Praveen JhaPraveen Jha

Hi pratik  thanks for reply, but there is one validation rule who don't allow specific profile to update case status through SF UI :-       


CONTAINS($Profile.Name, "Basic") && 
 ISCHANGED(Status) && 
NOT(ISNEW())

Can you check it for Basic profile.
PratikPratik (Salesforce Developers) 
Hi Praveen,

So all you need to bypass the validation rule when your case comment is added.

Follow these steps:

1. Create a Checkbox say Validationflag
2. Set it default as Unchecked.
3. Change you validation to add :

CONTAINS($Profile.Name, "Basic") && 
 ISCHANGED(Status) && 
NOT(ISNEW()) && (​Validationflag__c==false)


4. In your workflow on Cas comment add one more field update to Update the Checkbox on Case Validationflag = true.

5. Create a workflow rule on Case
Rule criteria: Case status= Working
Add Field update 
Validationflag =False.
This will ensure that Status can be changed only through Case comment.

This will work.

Thanks,
Pratik

P.S. If this answers you question, please mark it as "Best Answer" so it will help other community members too.
 
This was selected as the best answer
Praveen JhaPraveen Jha
Thanks Pratik. I have done all these things, but still status not getting update
Praveen JhaPraveen Jha
Hi Pratik,
Can you please send the workflow screenshots which you have created in your org?
Praveen JhaPraveen Jha
Hey Pratik thanks..now it's working . Many thanks for this
 
PratikPratik (Salesforce Developers) 
Glad it helped!

Thanks,
Pratik