Friday, June 1, 2012

How to Add VisualForce page in Standard Page Layout


Requirement: We have requirement when lead saved/created by Partner user then show popup alert message like Lead is saved not submitted.

Technical: Partner portal user creates Lead and Save it so it will open Lead standard page. So we need to add Alert message on this Standard page. We have two options given below:
Open 1: We can override the Lead’s View which is in
Setup>Object (Lead)>Standard Button and Link>View>Edit
First you have to create visualforce page which is getting the window on load alert message. Add this page to View override in Lead.

Open 2: We have another option like if we have visualforce page and add in to Page Layout. Which checks the Lead Status = ‘Draft’and Lead Category = ‘Opportunity Registration’ then show alert message to Portal user. We have created Visualforce page which satisfy above criteria and show alert message.

Visualforce Page OppRegAlertPage:

<apex:page standardController="Lead" tabStyle="Lead" >
<apex:form >
<apex:inputHidden value="{!Lead.Lead_Category__c}" id="LeadCategoryId"/>
<apex:inputHidden value="{!Lead.Status}" id="StatusId"/>
</apex:form>
<script language="javascript">
  var LdCategory;
  var LdStatus;
      LdCategory=document.getElementById('j_id0:j_id1:LeadCategoryId').value;
      LdStatus=document.getElementById('j_id0:j_id1:StatusId').value;    
   window.onload = function() {
    if( LdCategory == 'Opportunity Registration' && LdStatus =='Draft'){
           alert(‘Lead Saved but not Submitted!');
           }
   }
</script>
</apex:page>

I)   Setting>Go to Lead> Page Layout>Select page layout for Portal user>Edit
II)  Click on Edit Layout> Click on Visualforce pages>Select page > Drag and Drop in to Page
III) section>Double click on Page>
IV) Open Visualforce Page Properties> Width (in pixels or %)s=10%
                                                         Height (in pixels) = 0
                                                         Save Page Layout.

No comments:

Post a Comment