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
maddukurimaddukuri 

Case Button

Hi,

     On the case detail page, there is a button A. If any person other than the case owner clicks the button, an error message should pop up. Can anybody tell me how to accomplish this? Thanks in advance. 

asish1989asish1989

Hi 

   make a page . and overide that page with bottom

    here is my page and extension

       

<apex:page StandardController="Case" extensions="CaseExtension">
<apex:form >
<apex:pageMessages />
</apex:form>
</apex:page>

 

public class CaseExtension {
public Id caseid{get;set;}
public CaseExtension(ApexPages.StandardController controller){
caseid = controller.getId();
System.debug('################3username#########'+UserInfo.getUserId());
System.debug('################3Recordid#########'+controller.getId());

Case caseowner = [select id,OwnerId from Case where id =:caseid];
System.debug('################Caseowner#########'+caseowner.OwnerId );
if(UserInfo.getUserId() != caseowner.OwnerId){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.Error, 'You are not allowed to click this bottom.' );

ApexPages.addMessage(myMsg);
system.debug('MyMsg:'+myMsg);
}
else{
PageReference samepage= new PageReference('/'+caseid+'/e?retURL=%2'+caseid);
}
}
}

 

some part is not working... I have sloved up to user shows error if he is not owner . Now I am continueing owner part .

 

did this post answers your questions please mark it solved

 

thanks

asish

 

maddukurimaddukuri

Thank You Very Much for your time. I will try it out.