You need to sign in to do that
Don't have an account?
Ty Whitfield
Making Lightning VisualForce and Controller available in Classic
I've created a VF page with controller in Lightning. I found out that a department that hasn't migrated to Lightning yet also needs access. However, when I go to add the VF page to the page layout in Classic, it isn't shown. Is there a way to make it available in Classic.
Here is the VF page code
and here is the contoller code
Here is the VF page code
<apex:page lightningStylesheets="true" action="{!loadPage}" Controller="TrainingSubscriptionListController" > <!-- Begin Default Content REMOVE THIS --> <apex:outputtext value="{!tmp}" escape="false" id="tblHTML"/> <!-- End Default Content REMOVE THIS --> </apex:page>
and here is the contoller code
public class TrainingSubscriptionListController { @AuraEnabled Public List<Contact> acctContacts {get;set;} public string tmp {get;set;} public void loadPage(){ string AcctId = System.currentPageReference().getParameters().get('Id'); acctContacts = [Select Id, Training_Subscription_User__c, Name, Email from Contact where AccountId= :AcctId and Training_Subscription_User__c = true]; tmp = '<table id="myTable" style="width:100%; table-layout: auto;" cellspacing="0" cellpadding="10"><tr>' + '<td style="padding:15px; background-color: #0084c4 !important;background-image: none !important; color: #ffffff !important; font-size:100% !important; margin:0 !important; border:none !important;">' + '<b>Name</b></td>' + // '<td style="width:50px; background-color: #0084c4 !important;background-image: none !important; color: #ffffff !important; font-size:100% !important; margin:0 !important; border:none !important;">' + //'</td>' + '<td style=" background-color: #0084c4 !important;background-image: none !important; color: #ffffff !important; font-size:100% !important; margin:0 !important; border:none !important;">' + '<b>Email</b></td>' + '</tr>'; integer i = 0; while(i < acctContacts.size()) { tmp = tmp + '<tr><td style="padding:15px;"><a href="/' + acctContacts[i].Id + '">' + acctContacts[i].Name + '</a></td><td style="padding:5px;"><a href="/' + acctContacts[i].Id + '">' + acctContacts[i].Email + '</a></td></tr>'; i++; } tmp = tmp + '</table>'; } }
You can use below code:
Regards,
Khan Anas
All Answers
I trust you are doing very well.
To embed a Visualforce page into page layout, the Visualforce page should be using the standard controller tag referencing the same entity that will be used in the page layout. You can use or add this Visualforce page by modifying the page layout.
Reference: https://help.salesforce.com/articleView?id=000005105&language=en_US&type=1
Try below code:
Visualforce:
Controller:
After this, this page should show in the Page Layout editor and can be embedded on a page layout for Contact.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks and Regards,
Khan Anas
I now am wondering how that wll change my test class. Previously I tested using
Now I am receiving "Constructor not defined [TrainingSubscriptionListController].0"
You can use below code:
Regards,
Khan Anas