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
sravikasravika 

Restricting Case editing to all the users other then Case Owner

Hi,

 

I have a requirement on Case Object, where in only a Case Owner must be able to Close,Change Status (or simply Edit) the Cases  for which he is the Owner.

When users other than Case Owner tries changing the Status (picklist field on Case Object) he should be shown an error message saying that he is not the authorised one.

How to achieve this functionality using Validation Rule.

Please provide your inputs.

 

Thanks in Advance.

 

 

Regards,

Sravika

 

 

Best Answer chosen by Admin (Salesforce Developers) 
MarcPannenberg.ax1843MarcPannenberg.ax1843

I don't think you need a trigger for this. Try that:

 

AND(
ISCHANGED( Status ),
$User.Id <> OwnerId
)

 

Good luck!

All Answers

Dhaval PanchalDhaval Panchal

Instead of validation rule you can use below trigger.

 

trigger caseEdit on Case (after update) {
    for(Case cs:Trigger.new){
        if(cs.Status <> Trigger.oldMap.get(cs.Id).Status && userInfo.getUserId() <> cs.OwnerId){
            cs.AddError('You are not authorized user to change status');
            return;
        }
    }
}

 

MarcPannenberg.ax1843MarcPannenberg.ax1843

I don't think you need a trigger for this. Try that:

 

AND(
ISCHANGED( Status ),
$User.Id <> OwnerId
)

 

Good luck!

This was selected as the best answer
sravikasravika
Adding to this, what should be the rule if
Only case owners are authorized to edit the Case?
Its something like instead of changing "Status", now he should not be able to edit the case if he is not the Owner.
sravikasravika
I used in the following way.But its not working.

AND(RecordTypeId != '012J00000008mOg',
RecordTypeId != '012J00000008mOq', RecordTypeId != '012J00000008mOW',($User.Id <> OwnerId)).

For these record types,only case owners must be able to edit the Case.
MarcPannenberg.ax1843MarcPannenberg.ax1843

AND(

OR(

RecordTypeId != '012J00000008mOg',
RecordTypeId != '012J00000008mOq',

RecordTypeId != '012J00000008mOW'),

$User.Id <> OwnerId)

 

This means no one can do anything to cases with those 3 RT's, if he/she is not the owner. Be aware that this may impact any roll-ups, triggers, workflows, data loads, integrations, you might have.