You need to sign in to do that
Don't have an account?
Roshan 10
Is it possible to make a standard field (Case.Status) read only on the UI but user can still update it through a custom button (LWC component)
Hi,
On my case record in community, I want to prevent the user from updating the case by editing the Status field. The user should be able to close the case with the click of a custom button
Appreciate if anyone can provide their ideas
On my case record in community, I want to prevent the user from updating the case by editing the Status field. The user should be able to close the case with the click of a custom button
Appreciate if anyone can provide their ideas
As you have mentioned it is standrad & required field, so you cannot make it read only or remove it from Page Layout. It is always going to be on layout with editable mode.
So to tackle this situtation you can have a validation rule which will fire when you are updating the record from UI and you need to bypass the same when updating through apex. For Bypassing it through apex you need to have an extra field created on case which will help you determine that record is changin from UI or Button(Apex/LWC/or through code).
This is very well explained by Bob Buzzard in the below blog :
http://bobbuzzard.blogspot.com/2011/11/bypass-validation-rules-from-apex.html
Let me know if it helps.
Regards,
Santosh Kumar
All Answers
The LWC will call an Apex controller
Apex generally runs in system context; that is, the current user's permissions, field-level security, and sharing rules aren’t taken into account during code execution. You can try using without sharing
The edit access to the record is determined by the sharing access granted to the user, unless you declare the apex class as without sharing.
Apex executes in system mode so it would override FLS and be able to write to the field.
As you have mentioned it is standrad & required field, so you cannot make it read only or remove it from Page Layout. It is always going to be on layout with editable mode.
So to tackle this situtation you can have a validation rule which will fire when you are updating the record from UI and you need to bypass the same when updating through apex. For Bypassing it through apex you need to have an extra field created on case which will help you determine that record is changin from UI or Button(Apex/LWC/or through code).
This is very well explained by Bob Buzzard in the below blog :
http://bobbuzzard.blogspot.com/2011/11/bypass-validation-rules-from-apex.html
Let me know if it helps.
Regards,
Santosh Kumar