I am trying to create a Visualforce page that will overide the delete button on leads so that only certain users are allowed to delete leads. I keep geting errors when I try to save the page. I have pasted my Visualforce markup below. Does anyone know what I am doing wrong? Thanks in advance for your help!

<apex:page action="{!if($User.Alias !='KKing','HLemons','Dink','DPearse',
    urlFor($Action.Lead.Delete, $CurrentPage.Parameters.id, [retURL='/00Q'], true)
     <apex:pageBlock >
        <apex:PageMessage summary="You are not allowed to delete Leads"
        <apex:pageMessages />
  • It would likely be helpful if you posted what your errors were as well. – dphil Dec 11 '14 at 16:33
  • I speculate on the ACTION attribute in the page tag. Are you getting the error: "Syntax error" or "Incorrect number of parameters" or so? – Seesh Dec 11 '14 at 18:00

Changing the first line to:

<apex:page action="{!if(and($User.Alias != 'KKing', $User.Alias != 'HLemons', $User.Alias != 'Dink', $User.Alias != 'DPearse'),

will allow the page to compile.

| improve this answer | |

If the only objective of the VF page is to prevent users from deleting the records, the better option would be to write a Before Delete trigger and add an error message there.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.