-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
11Questions
-
8Replies
How do I reference a merge field containing a url as link in visualforce email template?
I have a visualforce email template that needs to read 'for more information click here'
The link is dynamic depending on the record that produces the email so the url is saved in a merge field on the record but when referencing this its not a clickable link:
You can find out more information <a href="{!relatedTo.Customobject__r.custom_url_field__c}"><strong><span style="font-size: 16px; font-family: Arial;"><strong style="font-weight: 700; color:black; font-family: Arial; font-size: 15px; text-decoration-style: underline; text-decoration-color: black !important;"><span style="font-size: 16px; font-family: Arial;">here</span></strong></span></strong></a></p>
The link is dynamic depending on the record that produces the email so the url is saved in a merge field on the record but when referencing this its not a clickable link:
You can find out more information <a href="{!relatedTo.Customobject__r.custom_url_field__c}"><strong><span style="font-size: 16px; font-family: Arial;"><strong style="font-weight: 700; color:black; font-family: Arial; font-size: 15px; text-decoration-style: underline; text-decoration-color: black !important;"><span style="font-size: 16px; font-family: Arial;">here</span></strong></span></strong></a></p>
- SazEast
- January 14, 2021
- Like
- 0
- Continue reading or reply
Is it possible to lookup a value of a field where the field name matches the value of another field?
For example:
Object | Field Name | Field Value |
Object 1 | Test | Car 2 |
Object 2 | Car 2 | Tyre |
I want to find the value 'Tyre' from the field name Car 2 when the value of Test = 'Car2'.
I want to be able to lookup the field value on object 1 if the field name matches the field value on object 2.
Many thanks!
- SazEast
- July 16, 2020
- Like
- 0
- Continue reading or reply
conditional render on visualforce email template
The below text should only be rendered if the picklist does not equal the two values but its not working, please could you help?
<apex:outputPanel rendered="{!IF(NOT(!relatedTo.Category__c ='Value1' || !relatedTo.Category__c ='Value 2' ,true,false))}> TEXT TO SHOW</apex:outputPanel>
- SazEast
- May 06, 2020
- Like
- 0
- Continue reading or reply
help with mapping JSON2Apex Class to Salesforce Object Fields
Hello, I'm a complete newbie to API integration - I have REST web service exposed to consume third party data which is to update records in Salesforce. I've got the JSON2Apex Class as the JSON is nested but unsure how to use this to map JSON fields/objects to Salesforce field names. I'm struggling to find any guidance online, please could someone point me in the right direction?
- SazEast
- March 06, 2020
- Like
- 0
- Continue reading or reply
Validation rule firing when it shouldn't
Hello,
Users are getting a validation error on records that are excluded from the validation rule. It should only fire for the three user profiles mentioned, and only fire if the approval status is set to 'Approved' if it was not already set to this. It also shouldn't fire if the record type is an invoice adjustment. Any ideas why this isn't working?
Thanks
Users are getting a validation error on records that are excluded from the validation rule. It should only fire for the three user profiles mentioned, and only fire if the approval status is set to 'Approved' if it was not already set to this. It also shouldn't fire if the record type is an invoice adjustment. Any ideas why this isn't working?
CONTAINS($Profile.Name, "Cash") || CONTAINS($Profile.Name, "RBC") || CONTAINS($Profile.Name, "Accounts Payable") && ISPICKVAL(Approval_Status__c, "Approved") && NOT(ISPICKVAL(PRIORVALUE(Approval_Status__c), "Approved") ) && RecordType.Name <> "Invoice_Adjustment"
Thanks
- SazEast
- February 05, 2020
- Like
- 0
- Continue reading or reply
help writing test class for a wrapper class which retrieves grandchild records
I'm getting a 'variable does not exist' error but it is in the wrapper class so i'm not sure what I'm doing wrong, please could you help with the test class code so I can deploy? Thanks
Wrapper Class:
Test Class:
Wrapper Class:
public class WrapperSarah{ public Consolidated_Invoicing__c consinvs; public WrapperSarah(ApexPages.StandardController stdController) { this.consinvs = (Consolidated_Invoicing__c)stdController.getRecord(); WrapperSarah wrp = new WrapperSarah(); } Id recordId; public List<Consolidated_Invoicing__c> consolidatedInvoiceList { get; set; } public List<Invoice__c> invoiceList { get; set; } public Map<Id, List<Invoice__c>> coninvIdinvListMap { get ; set; } Set<Id> invoiceIds = new Set<Id>(); Id Consolidated_InvoiceId = ApexPages.currentPage().getParameters().get('consId'); Map<Id, Consolidated_Invoicing__c> memberMap = new Map<Id, Consolidated_Invoicing__c>(); public List<ConsolidatedInvoiceWrapperSarah> consolidatedInvoiceWrapperSarahList { get; set; } public WrapperSarah() { consolidatedInvoiceList = [SELECT Total__c, Name FROM Consolidated_Invoicing__c Where Id =: ApexPages.currentPage().getParameters().get('id')]; coninvIdinvListMap = new Map<Id, List<Invoice__c>>(); consolidatedInvoiceWrapperSarahList = new List<ConsolidatedInvoiceWrapperSarah>(); if(consolidatedInvoiceList.size() > 0) { for (Consolidated_Invoicing__c cons: consolidatedInvoiceList) { invoiceIds.add(cons.Id); memberMap.put(cons.Id, cons); } invoiceList = [SELECT Name, Consolidated_Invoice__c, Patient_Name__c, PatientNameString__c, Hospital_Treated__c, Policy_Number__c, Consultant__c, DOB__c, (SELECT Name, Charge_Description__c, Charge_Code__c, Net_Price__c, Gross_Price__c, Line__c, Quantity__c, VAT__c, Date__c FROM Treatments__r) FROM Invoice__c WHERE Consolidated_Invoice__c IN : invoiceIds]; system.debug('Invoice List is ' + invoiceList); } if(invoiceList.size() > 0) { for(Invoice__c intrst : invoiceList) { if(!coninvIdinvListMap.containsKey(intrst.Consolidated_Invoice__c)){ coninvIdinvListMap.put(intrst.Consolidated_Invoice__c, new List<Invoice__c>()); } coninvIdinvListMap.get(intrst.Consolidated_Invoice__c).add(intrst); } for(Id invoiceId : coninvIdinvListMap.keySet()) { consolidatedInvoiceWrapperSarahList.add(new ConsolidatedInvoiceWrapperSarah(memberMap.get(invoiceId), coninvIdinvListMap.get(invoiceId))); } } } public class ConsolidatedInvoiceWrapperSarah { public Consolidated_Invoicing__c consinv { get; set; } public List<Invoice__c> invclist { get; set; } public ConsolidatedInvoiceWrapperSarah(Consolidated_Invoicing__c consinv, List<Invoice__c> invclist) { this.consinv= consinv; this.invclist = invclist; } } }
Test Class:
@IsTest private class TestWrapperSarah { @IsTest private static void WrapperSarah(){ Consolidated_Invoicing__c ci = new Consolidated_Invoicing__c(status__c='sent'); insert ci; string invclist=ci.ID; Invoice__c ni = new Invoice__c(); ni.Consolidated_Invoice__c = ci.Id; ni.Name = 'Fake'; insert ni; Treatment__c nt = new Treatment__c(); nt.Invoice__c = ni.Id; nt.Charge_Code__c = 'Fake Code'; nt.Date__c = Date.Today(); nt.Net_Price__c = 100.10; insert nt; Test.StartTest(); WrapperSarah co = new WrapperSarah(); system.assertEquals(1,WrapperSarah.invclist.size()); Test.stopTest(); } }
- SazEast
- May 08, 2019
- Like
- 0
- Continue reading or reply
apex:datatable columns not aligned
I have an apex:data table using width attributes but the alignment of the columns is not straight, for example:
I have text-align but how can I align / fix the columns?
Thanks
I have text-align but how can I align / fix the columns?
Thanks
- SazEast
- April 26, 2019
- Like
- 0
- Continue reading or reply
If I have inserted a visualforce page within a visual force page, would I have to use CSS styling markup on both pages?
It works fine on my main page but on the embedded page its displaying the css code as text on the output.
Thanks
Thanks
- SazEast
- April 25, 2019
- Like
- 0
- Continue reading or reply
standard controller and extension controller referencing issues
Hello,
I have a wrapper extension class that's intended to bring back grandchild records for a pageblock table within a Visualforce page. However, I keep getting errors when trying to save the Visualforce page referencing the extension controller. I'm not sure if there's a problem with the extension controller or the Visualforce page? Please see code below, any help is greatly appreciated!
VF Page:
<apex:page standardController="Consolidated_Invoicing__c" extensions="WrapperSarah" renderas="pdf">
Extension Controller:
public class WrapperSarah{
private final Consolidated_Invoicing__c consinvs;
public WrapperSarah(ApexPages.StandardController stdController) {
this.consinvs = (Consolidated_Invoicing__c)stdController.getRecord();
}
Can provide the full code if needed but only getting errors after this has been added in following a salesforce guide.
Thanks!
I have a wrapper extension class that's intended to bring back grandchild records for a pageblock table within a Visualforce page. However, I keep getting errors when trying to save the Visualforce page referencing the extension controller. I'm not sure if there's a problem with the extension controller or the Visualforce page? Please see code below, any help is greatly appreciated!
VF Page:
<apex:page standardController="Consolidated_Invoicing__c" extensions="WrapperSarah" renderas="pdf">
Extension Controller:
public class WrapperSarah{
private final Consolidated_Invoicing__c consinvs;
public WrapperSarah(ApexPages.StandardController stdController) {
this.consinvs = (Consolidated_Invoicing__c)stdController.getRecord();
}
Can provide the full code if needed but only getting errors after this has been added in following a salesforce guide.
Thanks!
- SazEast
- April 17, 2019
- Like
- 0
- Continue reading or reply
How do I display only the current record rather than all records using a custom wrapper class and visualforce page with an apex pageblocktable that shows the related records to the current object record?
How do I display only the current record rather than all records of an object (consolidated invoicing in this instance) using a custom wrapper class and visualforce page with an apex pageblocktable that shows the related records to the current object record (ie, all invoices and then treatments related to Consolidated invoices)?
Parent: Consolidated Invoicing
Child: Invoice
GrandChild: Treatments
I've created a wrapper class:
public class Wrapper{
public List<Consolidated_Invoicing__c> consolidatedInvoiceList { get; set; }
public List<Invoice__c> invoiceList { get; set; }
public Map<Id, List<Invoice__c>> coninvIdinvListMap { get; set; }
Set<Id> invoiceIds = new Set<Id>();
Map<Id, Consolidated_Invoicing__c> memberMap = new Map<Id, Consolidated_Invoicing__c>();
public List<ConsolidatedInvoiceWrapper> consolidatedInvoiceWrapperList { get; set; }
public Wrapper() {
consolidatedInvoiceList = [SELECT Total__c, Name FROM Consolidated_Invoicing__c];
coninvIdinvListMap = new Map<Id, List<Invoice__c>>();
consolidatedInvoiceWrapperList = new List<ConsolidatedInvoiceWrapper>();
if(consolidatedInvoiceList.size() > 0) {
for(Consolidated_Invoicing__c cons: consolidatedInvoiceList) {
invoiceIds.add(cons.Id);
memberMap.put(cons.Id, cons);
}
invoiceList = [SELECT Name, Consolidated_Invoice__c, (SELECT Name, Charge_Description__c FROM Treatments__r) FROM Invoice__c WHERE Consolidated_Invoice__c IN : invoiceIds];
system.debug('Invoice List is ' + invoiceList);
}
if(invoiceList.size() > 0) {
for(Invoice__c intrst : invoiceList) {
if(!coninvIdinvListMap.containsKey(intrst.Consolidated_Invoice__c)){
coninvIdinvListMap.put(intrst.Consolidated_Invoice__c, new List<Invoice__c>());
}
coninvIdinvListMap.get(intrst.Consolidated_Invoice__c).add(intrst);
}
for(Id invoiceId : coninvIdinvListMap.keySet()) {
consolidatedInvoiceWrapperList.add(new ConsolidatedInvoiceWrapper(memberMap.get(invoiceId), coninvIdinvListMap.get(invoiceId)));
}
}
}
public class ConsolidatedInvoiceWrapper{
public Consolidated_Invoicing__c consinv { get; set; }
public List<Invoice__c> invclist { get; set; }
public ConsolidatedInvoiceWrapper(Consolidated_Invoicing__c consinv, List<Invoice__c> invclist) {
this.consinv= consinv;
this.invclist = invclist;
}
}
}
And the the Visualforce page:
<apex:page Controller="Wrapper" renderas="pdf">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!consolidatedInvoiceWrapperList}" var="W">
<apex:column headerValue="Consolidated Invoice Number" value="{!W.consinv.Name}"/>
<apex:column headerValue="Total Amount Due" value="{!W.consinv.Total__c}"/>
<apex:column >
<apex:pageblockTable value="{!W.invclist }" var="I">
<apex:column headerValue= "Invoice Number" value="{!I.Name}"/>
<apex:column >
<apex:pageBlockTable value="{!I.Treatments__r}" var="E">
<apex:column headerValue="Charge Code" value="{!E.Name}"/>
<apex:column headerValue= "Description" value="{!E.Charge_Description__c}"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageblockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Is there something obvious i'm missing?
Thanks
Parent: Consolidated Invoicing
Child: Invoice
GrandChild: Treatments
I've created a wrapper class:
public class Wrapper{
public List<Consolidated_Invoicing__c> consolidatedInvoiceList { get; set; }
public List<Invoice__c> invoiceList { get; set; }
public Map<Id, List<Invoice__c>> coninvIdinvListMap { get; set; }
Set<Id> invoiceIds = new Set<Id>();
Map<Id, Consolidated_Invoicing__c> memberMap = new Map<Id, Consolidated_Invoicing__c>();
public List<ConsolidatedInvoiceWrapper> consolidatedInvoiceWrapperList { get; set; }
public Wrapper() {
consolidatedInvoiceList = [SELECT Total__c, Name FROM Consolidated_Invoicing__c];
coninvIdinvListMap = new Map<Id, List<Invoice__c>>();
consolidatedInvoiceWrapperList = new List<ConsolidatedInvoiceWrapper>();
if(consolidatedInvoiceList.size() > 0) {
for(Consolidated_Invoicing__c cons: consolidatedInvoiceList) {
invoiceIds.add(cons.Id);
memberMap.put(cons.Id, cons);
}
invoiceList = [SELECT Name, Consolidated_Invoice__c, (SELECT Name, Charge_Description__c FROM Treatments__r) FROM Invoice__c WHERE Consolidated_Invoice__c IN : invoiceIds];
system.debug('Invoice List is ' + invoiceList);
}
if(invoiceList.size() > 0) {
for(Invoice__c intrst : invoiceList) {
if(!coninvIdinvListMap.containsKey(intrst.Consolidated_Invoice__c)){
coninvIdinvListMap.put(intrst.Consolidated_Invoice__c, new List<Invoice__c>());
}
coninvIdinvListMap.get(intrst.Consolidated_Invoice__c).add(intrst);
}
for(Id invoiceId : coninvIdinvListMap.keySet()) {
consolidatedInvoiceWrapperList.add(new ConsolidatedInvoiceWrapper(memberMap.get(invoiceId), coninvIdinvListMap.get(invoiceId)));
}
}
}
public class ConsolidatedInvoiceWrapper{
public Consolidated_Invoicing__c consinv { get; set; }
public List<Invoice__c> invclist { get; set; }
public ConsolidatedInvoiceWrapper(Consolidated_Invoicing__c consinv, List<Invoice__c> invclist) {
this.consinv= consinv;
this.invclist = invclist;
}
}
}
And the the Visualforce page:
<apex:page Controller="Wrapper" renderas="pdf">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!consolidatedInvoiceWrapperList}" var="W">
<apex:column headerValue="Consolidated Invoice Number" value="{!W.consinv.Name}"/>
<apex:column headerValue="Total Amount Due" value="{!W.consinv.Total__c}"/>
<apex:column >
<apex:pageblockTable value="{!W.invclist }" var="I">
<apex:column headerValue= "Invoice Number" value="{!I.Name}"/>
<apex:column >
<apex:pageBlockTable value="{!I.Treatments__r}" var="E">
<apex:column headerValue="Charge Code" value="{!E.Name}"/>
<apex:column headerValue= "Description" value="{!E.Charge_Description__c}"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageblockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Is there something obvious i'm missing?
Thanks
- SazEast
- April 11, 2019
- Like
- 0
- Continue reading or reply
Community Builder - Adding an Edit Button on Record Detail Page
I'm using the Build Your Own Template in Community Builder, how do I add a standard or custom Edit button to the Record Detail Page?
- SazEast
- October 30, 2018
- Like
- 0
- Continue reading or reply
Is it possible to lookup a value of a field where the field name matches the value of another field?
For example:
Object | Field Name | Field Value |
Object 1 | Test | Car 2 |
Object 2 | Car 2 | Tyre |
I want to find the value 'Tyre' from the field name Car 2 when the value of Test = 'Car2'.
I want to be able to lookup the field value on object 1 if the field name matches the field value on object 2.
Many thanks!
- SazEast
- July 16, 2020
- Like
- 0
- Continue reading or reply
conditional render on visualforce email template
The below text should only be rendered if the picklist does not equal the two values but its not working, please could you help?
<apex:outputPanel rendered="{!IF(NOT(!relatedTo.Category__c ='Value1' || !relatedTo.Category__c ='Value 2' ,true,false))}> TEXT TO SHOW</apex:outputPanel>
- SazEast
- May 06, 2020
- Like
- 0
- Continue reading or reply
help with mapping JSON2Apex Class to Salesforce Object Fields
Hello, I'm a complete newbie to API integration - I have REST web service exposed to consume third party data which is to update records in Salesforce. I've got the JSON2Apex Class as the JSON is nested but unsure how to use this to map JSON fields/objects to Salesforce field names. I'm struggling to find any guidance online, please could someone point me in the right direction?
- SazEast
- March 06, 2020
- Like
- 0
- Continue reading or reply
Validation rule firing when it shouldn't
Hello,
Users are getting a validation error on records that are excluded from the validation rule. It should only fire for the three user profiles mentioned, and only fire if the approval status is set to 'Approved' if it was not already set to this. It also shouldn't fire if the record type is an invoice adjustment. Any ideas why this isn't working?
Thanks
Users are getting a validation error on records that are excluded from the validation rule. It should only fire for the three user profiles mentioned, and only fire if the approval status is set to 'Approved' if it was not already set to this. It also shouldn't fire if the record type is an invoice adjustment. Any ideas why this isn't working?
CONTAINS($Profile.Name, "Cash") || CONTAINS($Profile.Name, "RBC") || CONTAINS($Profile.Name, "Accounts Payable") && ISPICKVAL(Approval_Status__c, "Approved") && NOT(ISPICKVAL(PRIORVALUE(Approval_Status__c), "Approved") ) && RecordType.Name <> "Invoice_Adjustment"
Thanks
- SazEast
- February 05, 2020
- Like
- 0
- Continue reading or reply
help writing test class for a wrapper class which retrieves grandchild records
I'm getting a 'variable does not exist' error but it is in the wrapper class so i'm not sure what I'm doing wrong, please could you help with the test class code so I can deploy? Thanks
Wrapper Class:
Test Class:
Wrapper Class:
public class WrapperSarah{ public Consolidated_Invoicing__c consinvs; public WrapperSarah(ApexPages.StandardController stdController) { this.consinvs = (Consolidated_Invoicing__c)stdController.getRecord(); WrapperSarah wrp = new WrapperSarah(); } Id recordId; public List<Consolidated_Invoicing__c> consolidatedInvoiceList { get; set; } public List<Invoice__c> invoiceList { get; set; } public Map<Id, List<Invoice__c>> coninvIdinvListMap { get ; set; } Set<Id> invoiceIds = new Set<Id>(); Id Consolidated_InvoiceId = ApexPages.currentPage().getParameters().get('consId'); Map<Id, Consolidated_Invoicing__c> memberMap = new Map<Id, Consolidated_Invoicing__c>(); public List<ConsolidatedInvoiceWrapperSarah> consolidatedInvoiceWrapperSarahList { get; set; } public WrapperSarah() { consolidatedInvoiceList = [SELECT Total__c, Name FROM Consolidated_Invoicing__c Where Id =: ApexPages.currentPage().getParameters().get('id')]; coninvIdinvListMap = new Map<Id, List<Invoice__c>>(); consolidatedInvoiceWrapperSarahList = new List<ConsolidatedInvoiceWrapperSarah>(); if(consolidatedInvoiceList.size() > 0) { for (Consolidated_Invoicing__c cons: consolidatedInvoiceList) { invoiceIds.add(cons.Id); memberMap.put(cons.Id, cons); } invoiceList = [SELECT Name, Consolidated_Invoice__c, Patient_Name__c, PatientNameString__c, Hospital_Treated__c, Policy_Number__c, Consultant__c, DOB__c, (SELECT Name, Charge_Description__c, Charge_Code__c, Net_Price__c, Gross_Price__c, Line__c, Quantity__c, VAT__c, Date__c FROM Treatments__r) FROM Invoice__c WHERE Consolidated_Invoice__c IN : invoiceIds]; system.debug('Invoice List is ' + invoiceList); } if(invoiceList.size() > 0) { for(Invoice__c intrst : invoiceList) { if(!coninvIdinvListMap.containsKey(intrst.Consolidated_Invoice__c)){ coninvIdinvListMap.put(intrst.Consolidated_Invoice__c, new List<Invoice__c>()); } coninvIdinvListMap.get(intrst.Consolidated_Invoice__c).add(intrst); } for(Id invoiceId : coninvIdinvListMap.keySet()) { consolidatedInvoiceWrapperSarahList.add(new ConsolidatedInvoiceWrapperSarah(memberMap.get(invoiceId), coninvIdinvListMap.get(invoiceId))); } } } public class ConsolidatedInvoiceWrapperSarah { public Consolidated_Invoicing__c consinv { get; set; } public List<Invoice__c> invclist { get; set; } public ConsolidatedInvoiceWrapperSarah(Consolidated_Invoicing__c consinv, List<Invoice__c> invclist) { this.consinv= consinv; this.invclist = invclist; } } }
Test Class:
@IsTest private class TestWrapperSarah { @IsTest private static void WrapperSarah(){ Consolidated_Invoicing__c ci = new Consolidated_Invoicing__c(status__c='sent'); insert ci; string invclist=ci.ID; Invoice__c ni = new Invoice__c(); ni.Consolidated_Invoice__c = ci.Id; ni.Name = 'Fake'; insert ni; Treatment__c nt = new Treatment__c(); nt.Invoice__c = ni.Id; nt.Charge_Code__c = 'Fake Code'; nt.Date__c = Date.Today(); nt.Net_Price__c = 100.10; insert nt; Test.StartTest(); WrapperSarah co = new WrapperSarah(); system.assertEquals(1,WrapperSarah.invclist.size()); Test.stopTest(); } }
- SazEast
- May 08, 2019
- Like
- 0
- Continue reading or reply
standard controller and extension controller referencing issues
Hello,
I have a wrapper extension class that's intended to bring back grandchild records for a pageblock table within a Visualforce page. However, I keep getting errors when trying to save the Visualforce page referencing the extension controller. I'm not sure if there's a problem with the extension controller or the Visualforce page? Please see code below, any help is greatly appreciated!
VF Page:
<apex:page standardController="Consolidated_Invoicing__c" extensions="WrapperSarah" renderas="pdf">
Extension Controller:
public class WrapperSarah{
private final Consolidated_Invoicing__c consinvs;
public WrapperSarah(ApexPages.StandardController stdController) {
this.consinvs = (Consolidated_Invoicing__c)stdController.getRecord();
}
Can provide the full code if needed but only getting errors after this has been added in following a salesforce guide.
Thanks!
I have a wrapper extension class that's intended to bring back grandchild records for a pageblock table within a Visualforce page. However, I keep getting errors when trying to save the Visualforce page referencing the extension controller. I'm not sure if there's a problem with the extension controller or the Visualforce page? Please see code below, any help is greatly appreciated!
VF Page:
<apex:page standardController="Consolidated_Invoicing__c" extensions="WrapperSarah" renderas="pdf">
Extension Controller:
public class WrapperSarah{
private final Consolidated_Invoicing__c consinvs;
public WrapperSarah(ApexPages.StandardController stdController) {
this.consinvs = (Consolidated_Invoicing__c)stdController.getRecord();
}
Can provide the full code if needed but only getting errors after this has been added in following a salesforce guide.
Thanks!
- SazEast
- April 17, 2019
- Like
- 0
- Continue reading or reply
How do I display only the current record rather than all records using a custom wrapper class and visualforce page with an apex pageblocktable that shows the related records to the current object record?
How do I display only the current record rather than all records of an object (consolidated invoicing in this instance) using a custom wrapper class and visualforce page with an apex pageblocktable that shows the related records to the current object record (ie, all invoices and then treatments related to Consolidated invoices)?
Parent: Consolidated Invoicing
Child: Invoice
GrandChild: Treatments
I've created a wrapper class:
public class Wrapper{
public List<Consolidated_Invoicing__c> consolidatedInvoiceList { get; set; }
public List<Invoice__c> invoiceList { get; set; }
public Map<Id, List<Invoice__c>> coninvIdinvListMap { get; set; }
Set<Id> invoiceIds = new Set<Id>();
Map<Id, Consolidated_Invoicing__c> memberMap = new Map<Id, Consolidated_Invoicing__c>();
public List<ConsolidatedInvoiceWrapper> consolidatedInvoiceWrapperList { get; set; }
public Wrapper() {
consolidatedInvoiceList = [SELECT Total__c, Name FROM Consolidated_Invoicing__c];
coninvIdinvListMap = new Map<Id, List<Invoice__c>>();
consolidatedInvoiceWrapperList = new List<ConsolidatedInvoiceWrapper>();
if(consolidatedInvoiceList.size() > 0) {
for(Consolidated_Invoicing__c cons: consolidatedInvoiceList) {
invoiceIds.add(cons.Id);
memberMap.put(cons.Id, cons);
}
invoiceList = [SELECT Name, Consolidated_Invoice__c, (SELECT Name, Charge_Description__c FROM Treatments__r) FROM Invoice__c WHERE Consolidated_Invoice__c IN : invoiceIds];
system.debug('Invoice List is ' + invoiceList);
}
if(invoiceList.size() > 0) {
for(Invoice__c intrst : invoiceList) {
if(!coninvIdinvListMap.containsKey(intrst.Consolidated_Invoice__c)){
coninvIdinvListMap.put(intrst.Consolidated_Invoice__c, new List<Invoice__c>());
}
coninvIdinvListMap.get(intrst.Consolidated_Invoice__c).add(intrst);
}
for(Id invoiceId : coninvIdinvListMap.keySet()) {
consolidatedInvoiceWrapperList.add(new ConsolidatedInvoiceWrapper(memberMap.get(invoiceId), coninvIdinvListMap.get(invoiceId)));
}
}
}
public class ConsolidatedInvoiceWrapper{
public Consolidated_Invoicing__c consinv { get; set; }
public List<Invoice__c> invclist { get; set; }
public ConsolidatedInvoiceWrapper(Consolidated_Invoicing__c consinv, List<Invoice__c> invclist) {
this.consinv= consinv;
this.invclist = invclist;
}
}
}
And the the Visualforce page:
<apex:page Controller="Wrapper" renderas="pdf">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!consolidatedInvoiceWrapperList}" var="W">
<apex:column headerValue="Consolidated Invoice Number" value="{!W.consinv.Name}"/>
<apex:column headerValue="Total Amount Due" value="{!W.consinv.Total__c}"/>
<apex:column >
<apex:pageblockTable value="{!W.invclist }" var="I">
<apex:column headerValue= "Invoice Number" value="{!I.Name}"/>
<apex:column >
<apex:pageBlockTable value="{!I.Treatments__r}" var="E">
<apex:column headerValue="Charge Code" value="{!E.Name}"/>
<apex:column headerValue= "Description" value="{!E.Charge_Description__c}"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageblockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Is there something obvious i'm missing?
Thanks
Parent: Consolidated Invoicing
Child: Invoice
GrandChild: Treatments
I've created a wrapper class:
public class Wrapper{
public List<Consolidated_Invoicing__c> consolidatedInvoiceList { get; set; }
public List<Invoice__c> invoiceList { get; set; }
public Map<Id, List<Invoice__c>> coninvIdinvListMap { get; set; }
Set<Id> invoiceIds = new Set<Id>();
Map<Id, Consolidated_Invoicing__c> memberMap = new Map<Id, Consolidated_Invoicing__c>();
public List<ConsolidatedInvoiceWrapper> consolidatedInvoiceWrapperList { get; set; }
public Wrapper() {
consolidatedInvoiceList = [SELECT Total__c, Name FROM Consolidated_Invoicing__c];
coninvIdinvListMap = new Map<Id, List<Invoice__c>>();
consolidatedInvoiceWrapperList = new List<ConsolidatedInvoiceWrapper>();
if(consolidatedInvoiceList.size() > 0) {
for(Consolidated_Invoicing__c cons: consolidatedInvoiceList) {
invoiceIds.add(cons.Id);
memberMap.put(cons.Id, cons);
}
invoiceList = [SELECT Name, Consolidated_Invoice__c, (SELECT Name, Charge_Description__c FROM Treatments__r) FROM Invoice__c WHERE Consolidated_Invoice__c IN : invoiceIds];
system.debug('Invoice List is ' + invoiceList);
}
if(invoiceList.size() > 0) {
for(Invoice__c intrst : invoiceList) {
if(!coninvIdinvListMap.containsKey(intrst.Consolidated_Invoice__c)){
coninvIdinvListMap.put(intrst.Consolidated_Invoice__c, new List<Invoice__c>());
}
coninvIdinvListMap.get(intrst.Consolidated_Invoice__c).add(intrst);
}
for(Id invoiceId : coninvIdinvListMap.keySet()) {
consolidatedInvoiceWrapperList.add(new ConsolidatedInvoiceWrapper(memberMap.get(invoiceId), coninvIdinvListMap.get(invoiceId)));
}
}
}
public class ConsolidatedInvoiceWrapper{
public Consolidated_Invoicing__c consinv { get; set; }
public List<Invoice__c> invclist { get; set; }
public ConsolidatedInvoiceWrapper(Consolidated_Invoicing__c consinv, List<Invoice__c> invclist) {
this.consinv= consinv;
this.invclist = invclist;
}
}
}
And the the Visualforce page:
<apex:page Controller="Wrapper" renderas="pdf">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!consolidatedInvoiceWrapperList}" var="W">
<apex:column headerValue="Consolidated Invoice Number" value="{!W.consinv.Name}"/>
<apex:column headerValue="Total Amount Due" value="{!W.consinv.Total__c}"/>
<apex:column >
<apex:pageblockTable value="{!W.invclist }" var="I">
<apex:column headerValue= "Invoice Number" value="{!I.Name}"/>
<apex:column >
<apex:pageBlockTable value="{!I.Treatments__r}" var="E">
<apex:column headerValue="Charge Code" value="{!E.Name}"/>
<apex:column headerValue= "Description" value="{!E.Charge_Description__c}"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageblockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Is there something obvious i'm missing?
Thanks
- SazEast
- April 11, 2019
- Like
- 0
- Continue reading or reply