You need to sign in to do that
Don't have an account?
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>
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
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
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
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?
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.
Very odd...
Some random thoughts - swinging in the dark here.
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?
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 ...
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
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
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?