-
What is the pass Id of current record to Salesforce Apex Controller?
I'm working on a Visualforce Email Template which will be sent from the parent Loan (LLC_BI__Loan__c) record in Salesforce, and I'm trying to include fields from the child Entity Involvement (LLC_BI__Legal_Entities__c) record(s).
I'm attempting to pass the Loan record ID into the Controller using the ApexPages.StandardSetController method, but I think it may be failing due to the fact that the Visualforce component is being used in the email template and not on a record page.
I'm unable to pass the correct parent (Loan) Id to get the correct child records. Can anyone see where I may be going wrong ?
Thank you in advance.
Component: <apex:component controller="BorrowerRecordsFromLoans" access="global"> <apex:attribute name="currentRecordId" description="" assignTo="{!loanId}" type="Id"/> <apex:dataTable value="{!borrowerList}" var="borrower"> <apex:column > <apex:facet name="header">Borrower Name</apex:facet> {!borrower.LLC_BI__Account__r.Name} </apex:column> </apex:dataTable> </apex:component>
Controller: public class BorrowersOnLoans { public Id loanId {get;set;} private final LLC_BI__Loan__c loan; public BorrowersOnLoans (ApexPages.StandardSetController controller) { loan = (LLC_BI__Loan__c) controller.getRecord(); } public List<LLC_BI__Legal_Entities__c> getrelatedBorrowers() { List <LLC_BI__Legal_Entities__c> conList = New List<LLC_BI__Legal_Entities__c>(); for(LLC_BI__Loan__c ln: [SELECT id,name, (SELECT id, LLC_BI__Borrower_Type__c, LLC_BI__Account__r.Name FROM LLC_BI__Legal_Entities__r) FROM LLC_BI__Loan__c WHERE id = :loanId]) { for(LLC_BI__Legal_Entities__c con:ln.LLC_BI__Legal_Entities__r) conList.add(con); } return conList; } }
Log In to reply.
Popular Salesforce Blogs

Your Complete Guide to Salesforce Pardot
Pardot is a marketing automation platform similar to Marketing Cloud except it’s designed specifically for B2B contexts. It’s built with ease of use in mind,…

What is Lightning Web Runtime(LWR) in Salesforce?
Introduced in Spring 21, Experience Cloud's Build Your Own (LWR) Templates are lightweight templates that use the Experience Cloud's Lightning Web Runtime (LWR) platform. With…

Are You a Newbie Salesforce Developer?
All New Salesforce Developers Should Read This Article It all started when I was working on my very first project as a Salesforce Developer. I…
Popular Salesforce Videos
Salesforce is a fancy database
In this video, We will learn about the Salesforce Database (Data Modelling) in-depth in an interesting and fun way. I have divided this video into…
10 Example Future Method with Test Class | Asynchronous Apex | Salesforce Development Training Video
Salesforce uses a queue-based framework to handle asynchronous processes from such sources as future methods and batch Apex. This queue is used to balance request workload across…
360 SMS App Demo
360 SMS App is considered to be the most reliable Salesforce SMS App. This App is listed on the AppExchange from the name "360 SMS…
Popular Salesforce Infographics

Salesforce Admin Certification Path
The Salesforce Certified Administrator program is designed for individuals who have experience as a Salesforce administrator. The program encompasses the breadth of applications, the features…

CUSTOMER SERVICE TIPS: 4 SECRETS TO OFFERING EXCEPTIONAL CUSTOMER SERVICE
When it comes to customer service, our friends at Salesforce have a few tips and tricks up their sleeve. We were thrilled to help them illustrate four…

Success With Salesforce For Full Cycle Reps
I am presenting this infographic to help full cycle sales reps get the most out of salesforce and their Sales Engagement platform.