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
ChristadChristad 

Edit and Delete Command buttons not showing on VisualForce page

I am developing a custom VF page and added an edit and delete button using the <apex:commandButton action="{!edit}"/>  syntax (see code sample below). For some reason I am not able to view the buttons with this syntex even though I am a system administrator and have also checked that I have the correct privileges to view the buttons.

 

However when I use the urlfor syntax, the edit and delete buttons are displayed. I dont understand why the standard syntex do not display the buttons but using the urlfor syntax does. I have pasted a sample of the code below to demonstrate. Does anyone undestand why one works and the other doesnt ? Thanks in advance.

 

<apex:page standardController="Account" title="Sample Position Layout Page" showHeader="true" sidebar="true" >
   
    <apex:sectionHeader title="{!$ObjectType.Account.label}" subtitle="{!Account.name}"/>
      <apex:form >
      <apex:pageBlock title="Position Detail">
        <apex:pageBlockButtons >
            <apex:commandButton value="Edit" action="{!edit}"/>
            <apex:commandButton value="Edit2" action="{!URLFOR($Action.Account.Edit,Account.Id)}"/>
            <apex:commandButton value="Delete" action="{!delete}"/>
            <apex:commandButton value="Delete2" action="{!URLFOR($Action.Account.Delete,Account.Id)}"/>
            <apex:commandButton value="Sharing" onclick="window.top.location='{!URLFOR($Action.Account.Share,Account.Id)}'" />
        </apex:pageBlockButtons>
       
        <apex:pageBlockSection title="Information" columns="2">
            <apex:outputField value="{!Account.name}"/>
            <apex:outputField value="{!Account.ownerid}"/>                       
        </apex:pageBlockSection>

     </apex:pageBlock>
  </apex:form>
</apex:page>

Best Answer chosen by Christad
ChristadChristad

Just added the page to a button and the standard syntax for the edit and delete buttons displayed.

 

it appears that when you are developing the VF page eg using  https://..../apex/YOUR_PAGE_NAME?id=ANY_ACCOUNT_ID it does not display the edit and delete buttons using the standard syntax. However as soon as you add the VF page to a button and use it eg Customise | Accounts | buttons and Links and replace eg the View or button/link, it will display correctly. Is that normal? 

All Answers

Ankit AroraAnkit Arora

Am sure that "Edit" buttons are not displayed because you are not passing the Account Id in the URL.

 

Just pass the account Id in URL like this :

 

https://..../apex/YOUR_PAGE_NAME?id=ANY_ACCOUNT_ID

 

Buttons with standard action will only get displayed when you pass the Id to the standard controller.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

ChristadChristad

Hi Ankit and thanks for the response.

 

I should have mentioned it in my initial post that I did try that and unfortunately it doesnt seem to make any difference. It still doesnt display the edit and delete buttons but it will display the edit2 and delete2 buttons using the urlfor version. its very odd?

 

Regards

tom_patrostom_patros

Does the user accessing the VF page have edit and delete rights to that object type? Is this a VF page in the context of Force.com Sites?

ChristadChristad

Hi Tom

 

I havent deployed the VF page to the live environment as I am still developing the page in the sandbox. At the moment I am the system administrator and I've just had a quick look again to make sure I have all the CRUD permissions on the objects.

 

The VF page is intended to replace the standard page so I've not looked at it in terms of sites/portals functionality. Interestingly when I use the same code and just change the object to something else other than accounts, it still exhibits the same problem ie it doesnt display the edit and delete buttons but it does display the edit2 and delete2 buttons.

 

tom_patrostom_patros

Very odd...

 

Some random thoughts - swinging in the dark here.

 

  • Try the buttons outside of the <apex:pageBlockButtons> component
  • Try setting the "location" attribute on <apex:pageBlockButtons>
  • Try creating an extension with "edit" and "delete" methods (I know, you probably don't want to drag around extra code)

Also, per the VF docs: Command buttons and links that are associated with save, quicksave, edit, or delete actions in a standard controller are not rendered if the user does not have the appropriate permissions. Likewise if no particular record is associated with a page, command buttons and links associated with the edit and delete 

actions are not rendered.

 

Has me wondering about the record itself as previously noted in this thread. Do your other fields populate with values correctly? Are you passing the 15 or 18-character flavour of the ID?

ChristadChristad

Hi Tom

 

I tried the first two suggestions and neither seem to make any difference. Just to confirm , I am passing an AccountId to the VF page but the ID is 15chars long. Ive also recreated the test page documented above on to another SF instance and it also exhibits the same behaviour

 

Im puzzled by this behaviour ...

Ankit AroraAnkit Arora

This is really strange as your problem doesn't seems to get resolved by passing the Account Id in URL. Also am sure you have checked the CRUDE rights on the object for the profile (though system admin have all rights)

 

I request you to provide your entire code here and the exact URL your are hitting, and if still we are unable to help you then you should log a case for it.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

ChristadChristad

Hi Ankit

 

If you cut and paste the code posted in my first mesage, it will reproduce (at least for me) the problem. Regardless of what VF page I customise, the edit and delete button will not appear using the standard syntax.

 

As suggested, I will raise a case if I the problem is not identified

 

thanks

ChristadChristad

Just added the page to a button and the standard syntax for the edit and delete buttons displayed.

 

it appears that when you are developing the VF page eg using  https://..../apex/YOUR_PAGE_NAME?id=ANY_ACCOUNT_ID it does not display the edit and delete buttons using the standard syntax. However as soon as you add the VF page to a button and use it eg Customise | Accounts | buttons and Links and replace eg the View or button/link, it will display correctly. Is that normal? 

This was selected as the best answer
Rachita Jain 15Rachita Jain 15
Hi, I am also facing the same problem. Did you get any resolution for the same from Salesforce?
Jd M 6Jd M 6
Without getting any data how can we delete something.We must have a recod associated then only its possible right..You already got your answer but no where this basic fundamental amyone menioned so thought of putting it...