0

I have a VF page which I have added on the Account detail Page . I want to display this page only in Classic and hide the page completely in Lightning record detail page .To achieve this I added a rendering tag (rendered="{!!CONTAINS($CurrentPage.URL, 'lightning.force.com')}") which check the URL and hide the page from Lighting and show only in Classic .Though the page is not displaying in lightning,but it leaves a white space behind . Could you please help me on how to get rid of this whitespace?

Code :

<apex:page standardController="Account" lightningStylesheets="false" rendered="{!!CONTAINS($CurrentPage.URL, 'lightning.force.com')}" >
    <apex:outputField value="{!Account.name}"/>
    <!-- Adding Detailed section using OutputField -->  
    <apex:pageBlock title="Account Details">
    <apex:pageBlockSection >        
    <!--apex:detail relatedList="false"/ -->
            <apex:outputField value="{!Account.name}"/>
            <apex:outputField Value="{!Account.phone}"/>
            <apex:OutputField value="{!Account.Country__c}" />
            <apex:outputField Value="{!Account.State__c}" />
            <apex:outputField Value="{!Account.AnnualRevenue}" />
            {!Account.AnnualRevenue}    
    </apex:pageBlockSection>    
    </apex:pageBlock>
    
 <!-- Adding Releated List using PageBlockTable -->     
    <apex:pageBlock title="Associated Contacts" >       
         <apex:pageBlockTable value="{!Account.contacts}" var="con">      
         <apex:column value="{!con.Name}"/>
         <apex:Column value="{!con.Title}" />        
    </apex:pageBlockTable>    
    </apex:pageBlock>
    
    <apex:pageBlock title="Associated Opportunities">
    <apex:pageBlockTable value="{!Account.opportunities}" var="Oppty">
        <apex:column value="{!Oppty.name}"/>
        <apex:column value="{!Oppty.Type}"/>  
        <apex:column value="{!Oppty.stagename}"/>        
    </apex:pageBlockTable>
        
    </apex:pageBlock>   
 <!-- Adding Releated List using relatedList component -->     
<apex:relatedList list="Contacts"/> 
<apex:relatedList list="Opportunities" pageSize="5"/>
    <!-- /apex:outputPanel -->  
</apex:page>

This is how it looks on the lightning Account record page after hiding the VF page through rendering tag: REcord Detail Page Please help me on this

Thanks

1

2 Answers 2

0

Better option would be to enable dynamic forms from Lightning App Builder for lightning account record page. So you will be independent of the page layout.

It gives you the ability to control what you want to show in classic and lightning. See here -Enhance More Object Record Pages With Dynamic Forms And also this: Break Up Your Record Details with Dynamic Forms

Update

Once you enable the dynamic forms, You need to add the fields that you want on the layout. You can also set the field level visibility for each individual fields.

enter image description here

You can watch this video to understand the concept :- https://www.youtube.com/watch?v=Iatxjbuf3Qc

If you cannot go for Dynamic forms, there are two more approach i have:-

  1. Check this approach :- Dynamically resize VisualForce section in page layout
  2. You can just remove the detail component on lightning record page and create update a record quick action on account object. Then follow this approach to mimic the detail component in lightning:- POINT AND CLICK ALTERNATIVE TO LIGHTNING DATA SERVICE
4
  • Hi , Thank you for your answer . I tried enabling the Dynamic form for Account, and as soon as I enabled , my VF page disappeared without even adding a filter . I could just see the section now . So how to proceed on this? I have added a screenshot above . Please refer
    – SNSF
    Oct 22, 2022 at 10:40
  • @SNSF check my updated answer. Oct 22, 2022 at 15:17
  • Thank You for your detailed answer , I discussed this with my senior and currently they do not want to upgrade to Dynamic Forms , so is there a way we could fix this from VF page itself ? Kindly suggest
    – SNSF
    Oct 22, 2022 at 17:00
  • @SNSF I have added some more points, plz check. Oct 23, 2022 at 4:18
0

Have you considered using page layouts?

  1. One layout for users in classic, that'll have the vf page.
  2. Second layout for lightning experience users.

Off course you'll need to have record types for each page layout and assuming lightning users will be identified by their unique profile and like wise classic users will be identified by their profile.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .