On Salesforce Lightning records you can now include visualforce as a component.
For situations where you need to display information or dynamic UI from a query or calculation you can save a lot of time with visualforce components.
After creating this visualforce page make sure to enable it for lightning page use and drag it onto your lightning record page after clicking “edit page”.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
public class AccountVF_controller { public String var1 { get; set; } public String var2 { get; set; } public Account accountRecord{get; set;} public Contact contactRecord{get; set;} //Since this is the constructor (the same name as the controller) it is being called first. public AccountVF_controller() { accountRecord = [SELECT Id,name FROM Account WHERE id = :ApexPages.currentPage().getParameters().get('id') limit 1]; contactRecord = [SELECT Id,Firstname FROM Contact WHERE AccountID = :ApexPages.currentPage().getParameters().get('id') limit 1]; //OR you can get the id returned from the first query. This would be needed if you are trying to pass along a related record id. //contactRecord = [SELECT Id,name FROM Contact WHERE whatid = :accountRecord.id limit 1]; var1 = ApexPages.currentPage().getParameters().get('id'); var2 = contactRecord.id; } } |
1 2 3 4 5 6 7 8 |
<apex:page controller="AccountVF_controller"> Variable 1: {!var1} <br/> <br/> Variable 2: {!var2} </apex:page> |