1
votes

I have a client who has a custom visualforce page that is embedded on the standard Lead page via page layout. What they would like to do is have this embedded page appear conditionally based upon various criteria in the Lead Object. I have been able to implement this using a Home Page Component that uses javascript to find and hide the embedded content based on certain criteria it finds on screen. I have a couple questions about this technique:

  1. Is there a better way to accomplish this?
  2. How will Salesforce look upon this if they decide to create an AppExchange product out of this?

Thanks

3
This may be something you can use Visual Workflow for. I haven't used it, but it seems like it may fit your criteria. - Matt K
Couldn't your custom VF page use an apex:outputPanel to optionally rendered its entire content? - tggagne
absolutely, but the vf panel would still be taking up space on the Lead page. So we would end up with a blank area. - emanncsu

3 Answers

0
votes

I don't think it is possible. What you can do is to override the standard salesforce lead page with your custom Visualforce page. In your custom visualforce page you must to define a standard controller eg. standardController="Lead" and then output att the data of your Lead object with an apex tag apex:detail So you can create a custom page with a standard salesforce look and feel that you can control by yourself.

Infos: apex:detail and Overriding a Standard Page

0
votes

In case anyone is searching for an answer to this I will post how I resolved it - I used a Home Page Component and added it to the "Narrow Components to show". I also selected "Show Custom Sidebar Components on All Pages" in User Interface. This allowed me to embed a little javascript on each page. Next I added my vf page inside a section into the page layout for Leads (for example). I then looked for this section header and, if found call twistSection()

Here's a snippet:

Elements = document.getElementsByTagName('img');            
for (var i=Elements.length; i>0; i--) {                
if (Elements[i] != null) {
     if (Elements[i].attributes['alt'].value == 'Show Section - My Custom Panel') {
         twistSection(Elements[i]);
     }
}                   

}

I never found out if Salesforce frowns on the practice or not or if it will impact inclusion in the App Exchange or not.

0
votes

Another way to do this would be to simply use additional record types, that each have their own default page layouts. Include the VF elements on your new page layout assigned to the new record type. Then, based on the conditions/filters on the lead, WF rule to update the record type, thus changing the page layout that includes the VF elements. Very simple way to conditionally show VF on leads/records that meet certain criteria. We're doing this for a client, to essentially create a new record type for each existing record type and page layout they had to display a Visual Flow for certain records flagged at "At-Risk"