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
Colin LoretzColin Loretz 

Visualforce override is not going to correct URL

I have created a VF page to override the view of an object. The override is already setup so when I go to view the object by clicking on it in the Object's tab or in the Recent sidebar, the commandButtons (edit/delete) don't appear. The page renders as I coded it, minus those buttons.

The url for the view is composed of the salesforce url with the object Id
https://ssl.salesforce.com/a0M000000004KAT

If I go to
https://ssl.salesforce.com/apex/viewProject?id=a0M000000004KAT

The commandButtons show up. I'm not sure what is going on because the override should "transparently" allow for this connection to be made.

I also overrode the edit functionality and the Save/Cancel buttons do show up. It only seems to be a problem on the view.

My suspicion is in permissions but the profiles have access to edit/delete/save/view on all the objects and I can do all of those actions with a standard view.

Can anyone offer some insight on this? Thanks!
jwetzlerjwetzler
Do you mind posting the code for your page?  The smaller the example you can reduce it to the better (mostly, the fewer custom fields and things we have to worry about, the faster we can paste it into our test orgs).

Buttons do disappear/disable themselves based on permissions when used with the standardController, but I would not expect them to function any differently based on accessing the page through an override or accessing them directly.

Please use the src button when posting code.
Colin LoretzColin Loretz
Code:
<apex:page standardController="Project12h__c" >

 <apex:SectionHeader title="Project" subtitle="{!Project12h__c.Name}"/>
 
 <apex:Form>
 <apex:pageBlock title="Project Detail" >
 
  <apex:PageBlockButtons >
   <apex:commandButton value="Edit" action="{!edit}" id="editButton"/>
   <apex:commandButton value="Delete" action="{!delete}" onClick="return confirmDelete()" id="deleteButton" />
  </apex:PageBlockButtons>
  
  <apex:PageBlockSection >
   <apex:outputField value="{!Project12h__c.Name}" />
   <apex:outputField value="{!Project12h__c.Opportunity_Amount__c}" />
  </apex:PageBlockSection>
  
  <apex:PageBlockSection collapsible="true" title="Timeline">
   <apex:outputField value="{!Project12h__c.Start_Date__c}" />
   <apex:outputField value="{!Project12h__c.End_Date__c}" />
  </apex:PageBlockSection>
 
 </apex:pageBlock>
 </apex:Form>

 <apex:relatedList list="NotesAndAttachments" />

</apex:page>


The above is for my VF page: viewProject. I've stripped out alot of the variables for ease of use. Thanks Jill!
jwetzlerjwetzler
Hey Colin.  I am just not able to repro this.  I even made a custom object with those 3 custom fields on it so that I could paste your entire page into my org.

You don't have any weird CSS on your page that might be hiding those buttons do you?

You will lose those buttons if you don't supply an id to your page.  Notice that if you go to /apex/viewProject then your buttons disappear.  However the override should make the id available to you.  If you put {!Project12h__c.id} on your page does the id print out when you access it as an override?
Colin LoretzColin Loretz
This is definitely strange.

/apex/viewProject?id=a0M000000004KAT does indeed show the buttons.

With the override turned on, /a0M000000004KAT outputs the correct project data, including the ID but no Edit/Delete buttons.

I have not included any CSS on the page either.
Colin LoretzColin Loretz
Another observation I just discovered.

The buttons show up when I am viewing the page in Development Mode, even at the /a0M000000004KAT URL.

When I turn off development mode, the buttons are gone.
jwetzlerjwetzler
Definitely very wacky.  I was finally able to reproduce this (I was trying it out on the upcoming release rather than the current one, it seems that whatever is happening has already been fixed :)).

I'm not going to even pretend that I understand this, but while I was trying to find you a good workaround I found that if I added an extension to my page, the buttons came back.  If you add just an empty extension to your page does it work?
Colin LoretzColin Loretz
Jill,

Thank you so much for your help with something so wacky. Creating an empty extension actually worked.

Good to know that the issue is already fixed in the next version.

Cheers!
Colin