-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
7Questions
-
4Replies
Component error on Trailhead Geolocation app
Hello,
I am completing the Develop an Account Geolocation App with Aura Components Trail on Trailhead and though my components are functioning properly, every time I write something in the search bar (to query accounts) i get the following error
The error seems to be coming from the following controller in the "AccountMapController" class
The issue seems to be with this accounts.length;
What is length? it is not a custom field? is it the size of the Accounts list?
Any help to prevent this error would be great. I am trying to adapt this for my business
I am completing the Develop an Account Geolocation App with Aura Components Trail on Trailhead and though my components are functioning properly, every time I write something in the search bar (to query accounts) i get the following error
The error seems to be coming from the following controller in the "AccountMapController" class
({ onAccountsLoaded: function( component, event, helper ) { var mapMarkers = []; var accounts = event.getParam( 'accounts' ); for ( var i = 0; i < accounts.length; i++ ) { var account = accounts[i]; var marker = { 'location': { 'Street': account.BillingStreet, 'City': account.BillingCity, 'PostalCode': account.BillingPostalCode }, 'title': account.Name, 'description': ( 'Phone: ' + account.Phone + '<br/>' + 'Website: ' + account.Website ), 'icon': 'standard:location' }; mapMarkers.push( marker ); } component.set( 'v.mapMarkers', mapMarkers ); } })
The issue seems to be with this accounts.length;
What is length? it is not a custom field? is it the size of the Accounts list?
Any help to prevent this error would be great. I am trying to adapt this for my business
- Alex Waddell 18
- May 29, 2020
- Like
- 0
Limit apex repeat to 2 per page
Hello,
I am looking for a way to limit the number of tables created by an apex:repeat that appears on any given page.
I would like to limit the number to 2 per page. due to varying data, the tables vary in size. So sometimes the tables get pushed onto the next page causing a very ugly VF page as shown below
I am looking for a way to limit the number of tables created by an apex:repeat that appears on any given page.
I would like to limit the number to 2 per page. due to varying data, the tables vary in size. So sometimes the tables get pushed onto the next page causing a very ugly VF page as shown below
<apex:page Controller="ResourceListController" renderAs="PDF" > <apex:form > <div style="text-align:center"> <apex:image id="AdobeLogo" value="{!'/servlet/servlet.FileDownload?file= 0151R000004zUAh'}" width="50%" height="90" /> </div> <br></br> <br></br> <br></br> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. <br></br> <br></br> <br></br> Please contact Adobe Care and Wellness at 4807205699 for any questions regarding your Resource List. <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <div style="text-align:center"> <apex:image id="ArizonaLandScape" value="{!'/servlet/servlet.FileDownload?file= 0151R000005BPCa'}" width="75%" height="75%"/> </div> <div style="page-break-after:always;"> </div> <br></br> <br></br> <br></br> <apex:repeat var="RL" value="{!ResourceList}"> <table border="1" style="width:100%" > <tr> <th >Name</th> </tr> <tr> <td>{!RL.Account__r.Name}</td> </tr> <tr> <th>Description</th> </tr> <tr> <td>{!RL.Account__r.Description}</td> </tr> <tr> <th>Address</th> </tr> <tr> <td>{!RL.Account__r.BillingStreet}<br></br> {!RL.Account__r.BillingCity}, {!RL.Account__r.BillingState} {!RL.Account__r.BillingPostalCode} </td> </tr> </table> <table border="1" style="Width:100%"> <tr> <th>Phone</th><th>Type</th><th>Distance</th> </tr> <tr> <td>{!RL.Account__r.Phone}</td><td>{!RL.Type__c}</td><td>{!RL.Distance__c} miles</td> </tr> </table> <br></br> <br></br> <br></br> <br></br> <br></br> </Apex:Repeat> </apex:form> </apex:page>
- Alex Waddell 18
- May 18, 2020
- Like
- 0
SOQL query "Order By" causing Test to fail
Hello,
I am getting an error when running my test class. The error is coming from my Controller class where a SOQL query uses the ORDER BY clause
Any ideas on how to overcome this error?
Error
I am getting an error when running my test class. The error is coming from my Controller class where a SOQL query uses the ORDER BY clause
Any ideas on how to overcome this error?
Error
System.QueryException: unexpected token: 'BY' Class.ResourceListController.getResourceList: line 5, column 1 Class.resourceListTestClass.testMethod1: line 70, column 1Controller
public class ResourceListController { public Id RecordId {get;set;} public List<Resource_List__c> getResourceList() { RecordId = ApexPages.currentPage().getParameters().get('id'); List<Resource_List__c> results = Database.query( 'SELECT Id, Account__c, Account__r.Name, Distance__c, type__c, Account__r.Phone, Account__r.Description, Account__r.billingStreet, Account__r.billingCity, Account__r.billingPostalCode, Account__r.billingState ' + 'FROM Resource_List__c ' + 'Where Social_Services_Assessment__c = :RecordId' + 'ORDER BY Type__c asc, Distance__c asc' ); return results; } }Test Class
@isTest public class resourceListTestClass { static testMethod void testMethod1() { Account ta = new Account(); ta.name = 'Alex Demo'; ta.First_Name__c = 'Alex'; ta.Surname__c = 'Demo'; ta.Primary_Insurance__c = 'Test Insurance Company'; ta.Gender__c ='Male'; ta.County__c ='Yavapai'; ta.BillingStreet = '123 West Gurley Street'; ta.BillingCity = 'Prescott'; ta.BillingState = 'Arizona'; ta.BillingPostalCode = '86303'; ta.RecordTypeId = '012360000004FEPAA2'; insert ta; Social_Services_Assesment__c sw = new Social_Services_Assesment__c (); sw.Account__c = ta.Id; sw.Radius_in_miles__c = 25; sw.Monthly_income__c = 5000; sw.Do_you_have_enough_money_each_month__c = 'No'; sw.Do_you_recieve_SSI__c = 'No'; sw.Do_you_receive_SSDI__c = 'No'; sw.Do_you_receive_food_assistance__c = 'No'; sw.Do_you_receive_cash_assistance__c = 'No'; sw.Do_you_have_adequate_shelter__c = 'No'; sw.Do_you_need_congregate_meals__c = 'Yes'; sw.Do_you_need_transportation__c = 'Yes'; sw.Do_you_have_enough_money_each_month__c = 'No'; sw.Can_you_pay_for_your_housing__c = 'No'; sw.Can_you_pay_your_utilities__c = 'No'; sw.Can_you_pay_for_transportation__c = 'No'; sw.Can_you_pay_for_medical_visits__c = 'No'; sw.Are_you_unemployed__c = 'Yes'; sw.SSI_SSDI_decreased__c = 'Yes'; sw.RecordTypeId = '0121R000000yZUyQAM'; insert sw; Account r1 = new Account (); r1.RecordTypeId = '0121R000000yZGLQA2'; r1.Name = 'Resource 1'; r1.Food_Bank__c = true; r1.Financial_Assistance__c = true; insert r1; Account r2 = new Account (); r2.RecordTypeId = '0121R000000yZGLQA2'; r2.Name = 'Resource 2'; r2.Food_Bank__c = true; r2.Financial_Assistance__c = true; insert r2; Resource_List__c RL1 = new Resource_List__c (); RL1.Account__c = r1.Id; RL1.Social_Services_Assessment__c = sw.id; RL1.Type__c = 'Food Bank'; insert RL1; Resource_List__c RL2 = new Resource_List__c (); RL2.Account__c = r2.Id; RL2.Social_Services_Assessment__c = sw.id; RL2.Type__c = 'Food Bank'; insert RL2; test.StartTest(); PageReference PageRef = Page.ResourceList; test.setCurrentpage(PageRef); System.currentPageReference().getParameters().put('RecordId',sw.Id); ResourceListController obj = new ResourceListController(); obj.getResourceList(); test.StopTest(); } }
- Alex Waddell 18
- May 14, 2020
- Like
- 0
Help writing test class for VF Page
Hello, I am trying to write a test class for the following VF Page
I wrote a test class but I am getting 0% code coverage for the controller I am trying to test...
VF Page:
I wrote a test class but I am getting 0% code coverage for the controller I am trying to test...
VF Page:
<apex:page Controller="ResourceListController" renderAs="PDF" > <apex:form > <apex:image id="AdobeLogo" value="{!'/servlet/servlet.FileDownload?file= 0152f0000009UPQ'}" width="100%" height="125"/> <br></br> <br></br> <br></br> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. <br></br> <br></br> <br></br> Please contact Adobe Care and Wellness at 4807205699 for any questions regarding your Resource List. <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <div style="text-align:center"> <apex:image id="ArizonaLandScape" value="{!'/servlet/servlet.FileDownload?file= 0152f0000009Uhy'}" width="75%" height="75%"/> </div> <div style="page-break-after:always;"> </div> <br></br> <br></br> <br></br> <apex:repeat var="RL" value="{!ResourceList}"> <table border="1" style="width:100%" > <tr> <th >Name</th> </tr> <tr> <td>{!RL.Account__r.Name}</td> </tr> <tr> <th>Description</th> </tr> <tr> <td>{!RL.Account__r.Description}</td> </tr> <tr> <th>Address</th> </tr> <tr> <td>{!RL.Account__r.BillingStreet}<br></br> {!RL.Account__r.BillingCity}, {!RL.Account__r.BillingState} {!RL.Account__r.BillingPostalCode} </td> </tr> </table> <table border="1" style="Width:100%"> <tr> <th>Phone</th><th>Type</th><th>Distance</th> </tr> <tr> <td>{!RL.Account__r.Phone}</td><td>{!RL.Type__c}</td><td>{!RL.Distance__c} miles</td> </tr> </table> <br></br> <br></br> <br></br> <br></br> <br></br> </Apex:Repeat> </apex:form> </apex:page>Controller
public class ResourceListController { public Id RecordId {get;set;} public List<Resource_List__c> getResourceList() { RecordId = ApexPages.currentPage().getParameters().get('id'); List<Resource_List__c> results = Database.query( 'SELECT Id, Account__c, Account__r.Name, Distance__c, type__c, Account__r.Phone, Account__r.Description, Account__r.billingStreet, Account__r.billingCity, Account__r.billingPostalCode, Account__r.billingState ' + 'FROM Resource_List__c ' + 'Where Social_Services_Assessment__c = :RecordId' + 'ORDER BY Type__c asc, Distance__c asc' ); return results; } }Test Class
@isTest public class resourceListTestClass { static testMethod void testMethod1() { Account ta = new Account(); ta.name = 'Alex Demo'; ta.First_Name__c = 'Alex'; ta.Surname__c = 'Demo'; ta.Primary_Insurance__c = 'Test Insurance Company'; ta.Gender__c ='Male'; ta.County__c ='Yavapai'; ta.BillingStreet = '123 West Gurley Street'; ta.BillingCity = 'Prescott'; ta.BillingState = 'Arizona'; ta.BillingPostalCode = '86303'; ta.RecordTypeId = '012360000004FEPAA2'; insert ta; Social_Services_Assesment__c sw = new Social_Services_Assesment__c (); sw.Account__c = ta.Id; sw.Radius_in_miles__c = 25; sw.Monthly_income__c = 5000; sw.Do_you_have_enough_money_each_month__c = 'No'; sw.Do_you_recieve_SSI__c = 'No'; sw.Do_you_receive_SSDI__c = 'No'; sw.Do_you_receive_food_assistance__c = 'No'; sw.Do_you_receive_cash_assistance__c = 'No'; sw.Do_you_have_adequate_shelter__c = 'No'; sw.Do_you_need_congregate_meals__c = 'Yes'; sw.Do_you_need_transportation__c = 'Yes'; sw.Do_you_have_enough_money_each_month__c = 'No'; sw.Can_you_pay_for_your_housing__c = 'No'; sw.Can_you_pay_your_utilities__c = 'No'; sw.Can_you_pay_for_transportation__c = 'No'; sw.Can_you_pay_for_medical_visits__c = 'No'; sw.Are_you_unemployed__c = 'Yes'; sw.SSI_SSDI_decreased__c = 'Yes'; sw.RecordTypeId = '0121R000000yZUyQAM'; insert sw; Account r1 = new Account (); r1.RecordTypeId = '0121R000000yZGLQA2'; r1.Name = 'Resource 1'; r1.Food_Bank__c = true; r1.Financial_Assistance__c = true; insert r1; Account r2 = new Account (); r2.RecordTypeId = '0121R000000yZGLQA2'; r2.Name = 'Resource 2'; r2.Food_Bank__c = true; r2.Financial_Assistance__c = true; insert r2; Resource_List__c RL1 = new Resource_List__c (); RL1.Account__c = r1.Id; RL1.Social_Services_Assessment__c = sw.id; insert RL1; Resource_List__c RL2 = new Resource_List__c (); RL2.Account__c = r2.Id; RL2.Social_Services_Assessment__c = sw.id; insert RL2; Test.StartTest(); PageReference PageRef = Page.ResourceList; Test.setCurrentpage(PageRef); System.currentPageReference().getParameters().put('RecordId',sw.Id); ResourceListController controller = new ResourceListController(); Test.StopTest(); } }
- Alex Waddell 18
- May 14, 2020
- Like
- 0
Pass Record Id into Visual Force page
I am learning Apex and am trying to get my controller to query for Resource_List__c records where the Survey_Form__c field = :RecordId (the current Survery_Form__c record I am viewing)
VF Page
Class
VF Page Output when on the Lightning page
but when I put the query into the query editor and hard code the record Id there are values in this table
Is there any way to pass the record id into the VF page without invoking aura or LWC? I just want to learn the fundamentals before I step into those new languages
VF Page
<apex:page Controller="ResourceListController"> <apex:form> <apex:pageBlock> <apex:pageBlockTable value="{! ResourceList }" var="RL"> <apex:column value="{! RL.Id }"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Class
public class ResourceListController { public Id RecordId {get;set;} public List<Resource_List__c> getResourceList() { List<Resource_List__c> results = Database.query( 'SELECT Id, Account__c, Distance__c, type__c ' + 'FROM Resource_List__c ' + 'Where Survey_Form__c = :RecordId ' ); return results; } }
VF Page Output when on the Lightning page
but when I put the query into the query editor and hard code the record Id there are values in this table
Is there any way to pass the record id into the VF page without invoking aura or LWC? I just want to learn the fundamentals before I step into those new languages
- Alex Waddell 18
- March 17, 2020
- Like
- 0
SObject row was retrieved via SOQL without querying the requested field: Preventative_Screening__c.Account__r
I am getting the following error when I remove an <apex:outputText value/> from a visual force page
SObject row was retrieved via SOQL without querying the requested field: Preventative_Screening__c.Account__r
An unexpected error has occurred. Your development organization has been notified.
Here is the code before removing the field output
Page:
VF Page after removing apexOutput
Image of error
Any ideas on how to successfully remove this Apex outputfield and avoid this error?
SObject row was retrieved via SOQL without querying the requested field: Preventative_Screening__c.Account__r
An unexpected error has occurred. Your development organization has been notified.
Here is the code before removing the field output
Page:
<apex:page standardController="Preventative_Screening__c" extensions="ContractDocumentExtDIABTest" docType="html-5.0" showHeader="false" sidebar="false" standardStylesheets="false" id="thePage"> <apex:stylesheet value="{!URLFOR($Resource.slds120,'assets/styles/salesforce-lightning-design-system.css')}"/> <apex:form id="theForm"> <div> </div> <div align="Left" id="PatentInfo"> <apex:outputText value="{!Preventative_Screening__c.Account__r.name}"/><br/> <div style="width:100%;"> <div style="float:left;"> <div style="display:{!IF(caseManagerSign != Null,'block','None')} "> <apex:image url="{!URLFOR($Action.Attachment.Download, caseManagerSign.Id)}" rendered="{!caseManagerSign != Null}" width="30%" height="30%"/><br/> <apex:outputLabel value="Signed By: "/> <apex:outputText value="{!Preventative_Screening__c.Last_Modified_for_App__c}" /><br/> </div> </div> </div> </div> </apex:form> </apex:page>Extension
/*Description : This class is a controller extension for 'Contract_Template' Page. This class contians the functionality to send email to the Customer and render the PDF for display*/ public Class ContractDocumentExtDIABTest{ public Preventative_Screening__c contractDocument{get;set;} Public Attachment patientSign{get;set;} Public Attachment caseManagerSign{get;set;} public String chooserender{get;set;} Public List<contact> currContactLst; public ContractDocumentExtDIABTest(ApexPages.StandardController stdController){ String parentid; contractDocument= (Preventative_Screening__c) stdController.getRecord(); if(contractDocument != Null){ currContactLst = [SELECT ID FROM Contact WHERE Accountid = : contractDocument.Account__r.id]; } List<Attachment> attachmentLst = [SELECT ID,CreatedDate FROM Attachment WHERE parentId =: contractDocument.id order by CreatedDate asc ]; if(attachmentLst.size() == 1){ caseManagerSign = attachmentLst[0]; } if(attachmentLst.size() == 2){ caseManagerSign = attachmentLst[0]; patientSign = attachmentLst[1]; } if(ApexPages.currentPage().getParameters().get('renderAs') != null){ chooserender = 'print'; }else{ chooserender = Null; } } /*public void sendEmail(){ contractDocument = [SELECT ID,Account__r.email__c,Account__r.id FROM Preventative_Screening__c WHERE ID =:contractDocument.id ]; if(contractDocument.Account__r.email__c == Null || currContactLst.size() == 0 ){ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,'Please enter the Email address in Account')); }else{ System.PageReference currentPage = ApexPages.currentPage(); Blob pdfData = currentPage.getContentAsPDF(); Messaging.EmailFileAttachment emailMessage = new Messaging.EmailFileAttachment(); emailMessage.setContentType('application/pdf'); emailMessage.setFileName('Contact.pdf'); emailMessage.setInline(false); if (Test.IsRunningTest()){ emailMessage.Body = Blob.valueOf('UNIT.TEST'); }else{ emailMessage.Body = pdfData; } try{ List<Messaging.SingleEmailMessage> emailMessageLst= new List<Messaging.SingleEmailMessage>(); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[] {contractDocument.Account.email__c}; mail.setToAddresses(toAddresses); EmailTemplate currEmailTemplate = [SELECT ID from EmailTemplate WHERE Name = : Label.Email_Template_Name_for_Contract_Document]; mail.setTemplateId(currEmailTemplate.id); mail.setWhatId(contractDocument.Account__r.id); mail.setTargetObjectId(currContactLst[0].id); mail.setTreatTargetObjectAsRecipient(true); mail.setSaveAsActivity(true); mail.setFileAttachments(new Messaging.EmailFileAttachment[] { emailMessage}); emailMessageLst.add(mail); Messaging.sendEmail(emailMessageLst); }Catch(Exception ex){ System.debug('Exception Message'+ex.getmessage()); } ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Email sent successfully')); } }*/ }Photo of VF Page working
VF Page after removing apexOutput
<apex:page standardController="Preventative_Screening__c" extensions="ContractDocumentExtDIABTest" docType="html-5.0" showHeader="false" sidebar="false" standardStylesheets="false" id="thePage"> <apex:stylesheet value="{!URLFOR($Resource.slds120,'assets/styles/salesforce-lightning-design-system.css')}"/> <apex:form id="theForm"> <div> </div> <div align="Left" id="PatentInfo"> <div style="width:100%;"> <div style="float:left;"> <div style="display:{!IF(caseManagerSign != Null,'block','None')} "> <apex:image url="{!URLFOR($Action.Attachment.Download, caseManagerSign.Id)}" rendered="{!caseManagerSign != Null}" width="30%" height="30%"/><br/> <apex:outputLabel value="Signed By: "/> <apex:outputText value="{!Preventative_Screening__c.Last_Modified_for_App__c}" /><br/> </div> </div> </div> </div> </apex:form> </apex:page>
Image of error
Any ideas on how to successfully remove this Apex outputfield and avoid this error?
- Alex Waddell 18
- January 31, 2020
- Like
- 0
Running into SOQL Query limit 101 when importing data using data loader
I am running into an error when mass creating assessments using dataloader.
I have a feeling that I running 3 queries inside of the For() is the cause of my issue. Can someone help me rework this code to avoid these issues moving forward?
I have a feeling that I running 3 queries inside of the For() is the cause of my issue. Can someone help me rework this code to avoid these issues moving forward?
trigger closeCaseOnIcmDischarge on Patient_Ass__c (After insert) { for(Patient_ass__c pAss : trigger.new){ Patient_Assessment_View__c pView = [Select id,Account__c From Patient_Assessment_View__C Where id = :pAss.Patient_Assessment_View__c]; List <Case> c = [Select id, Discharge_Reason__c, Discharge_Date__c, Accountid From Case Where status IN('New','On Service') AND RecordTypeId = '01236000000OJLq' And Accountid = :Pview.Account__c Limit 1]; List <TeleWell_Care_Plan__c> TW = [Select id,Use_Question_1__c From Telewell_Care_Plan__c Where Patient_Assessment_and_Care_Plan__c = :Pview.id LIMIT 1] ; if(c.size() > 0 && pAss.RecordTypeId == '01236000000nufHAAQ'){ c.get(0).status ='Closed'; c.get(0).Discharge_Reason__c = pAss.Discharge_Reason__c; c.get(0).Discharge_Date__c = System.today(); Update c; TW.get(0).Use_question_1__c = 'No'; Update TW; } Else{ } } }
- Alex Waddell 18
- December 17, 2019
- Like
- 0
SOQL query "Order By" causing Test to fail
Hello,
I am getting an error when running my test class. The error is coming from my Controller class where a SOQL query uses the ORDER BY clause
Any ideas on how to overcome this error?
Error
I am getting an error when running my test class. The error is coming from my Controller class where a SOQL query uses the ORDER BY clause
Any ideas on how to overcome this error?
Error
System.QueryException: unexpected token: 'BY' Class.ResourceListController.getResourceList: line 5, column 1 Class.resourceListTestClass.testMethod1: line 70, column 1Controller
public class ResourceListController { public Id RecordId {get;set;} public List<Resource_List__c> getResourceList() { RecordId = ApexPages.currentPage().getParameters().get('id'); List<Resource_List__c> results = Database.query( 'SELECT Id, Account__c, Account__r.Name, Distance__c, type__c, Account__r.Phone, Account__r.Description, Account__r.billingStreet, Account__r.billingCity, Account__r.billingPostalCode, Account__r.billingState ' + 'FROM Resource_List__c ' + 'Where Social_Services_Assessment__c = :RecordId' + 'ORDER BY Type__c asc, Distance__c asc' ); return results; } }Test Class
@isTest public class resourceListTestClass { static testMethod void testMethod1() { Account ta = new Account(); ta.name = 'Alex Demo'; ta.First_Name__c = 'Alex'; ta.Surname__c = 'Demo'; ta.Primary_Insurance__c = 'Test Insurance Company'; ta.Gender__c ='Male'; ta.County__c ='Yavapai'; ta.BillingStreet = '123 West Gurley Street'; ta.BillingCity = 'Prescott'; ta.BillingState = 'Arizona'; ta.BillingPostalCode = '86303'; ta.RecordTypeId = '012360000004FEPAA2'; insert ta; Social_Services_Assesment__c sw = new Social_Services_Assesment__c (); sw.Account__c = ta.Id; sw.Radius_in_miles__c = 25; sw.Monthly_income__c = 5000; sw.Do_you_have_enough_money_each_month__c = 'No'; sw.Do_you_recieve_SSI__c = 'No'; sw.Do_you_receive_SSDI__c = 'No'; sw.Do_you_receive_food_assistance__c = 'No'; sw.Do_you_receive_cash_assistance__c = 'No'; sw.Do_you_have_adequate_shelter__c = 'No'; sw.Do_you_need_congregate_meals__c = 'Yes'; sw.Do_you_need_transportation__c = 'Yes'; sw.Do_you_have_enough_money_each_month__c = 'No'; sw.Can_you_pay_for_your_housing__c = 'No'; sw.Can_you_pay_your_utilities__c = 'No'; sw.Can_you_pay_for_transportation__c = 'No'; sw.Can_you_pay_for_medical_visits__c = 'No'; sw.Are_you_unemployed__c = 'Yes'; sw.SSI_SSDI_decreased__c = 'Yes'; sw.RecordTypeId = '0121R000000yZUyQAM'; insert sw; Account r1 = new Account (); r1.RecordTypeId = '0121R000000yZGLQA2'; r1.Name = 'Resource 1'; r1.Food_Bank__c = true; r1.Financial_Assistance__c = true; insert r1; Account r2 = new Account (); r2.RecordTypeId = '0121R000000yZGLQA2'; r2.Name = 'Resource 2'; r2.Food_Bank__c = true; r2.Financial_Assistance__c = true; insert r2; Resource_List__c RL1 = new Resource_List__c (); RL1.Account__c = r1.Id; RL1.Social_Services_Assessment__c = sw.id; RL1.Type__c = 'Food Bank'; insert RL1; Resource_List__c RL2 = new Resource_List__c (); RL2.Account__c = r2.Id; RL2.Social_Services_Assessment__c = sw.id; RL2.Type__c = 'Food Bank'; insert RL2; test.StartTest(); PageReference PageRef = Page.ResourceList; test.setCurrentpage(PageRef); System.currentPageReference().getParameters().put('RecordId',sw.Id); ResourceListController obj = new ResourceListController(); obj.getResourceList(); test.StopTest(); } }
- Alex Waddell 18
- May 14, 2020
- Like
- 0
Help writing test class for VF Page
Hello, I am trying to write a test class for the following VF Page
I wrote a test class but I am getting 0% code coverage for the controller I am trying to test...
VF Page:
I wrote a test class but I am getting 0% code coverage for the controller I am trying to test...
VF Page:
<apex:page Controller="ResourceListController" renderAs="PDF" > <apex:form > <apex:image id="AdobeLogo" value="{!'/servlet/servlet.FileDownload?file= 0152f0000009UPQ'}" width="100%" height="125"/> <br></br> <br></br> <br></br> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. <br></br> <br></br> <br></br> Please contact Adobe Care and Wellness at 4807205699 for any questions regarding your Resource List. <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <div style="text-align:center"> <apex:image id="ArizonaLandScape" value="{!'/servlet/servlet.FileDownload?file= 0152f0000009Uhy'}" width="75%" height="75%"/> </div> <div style="page-break-after:always;"> </div> <br></br> <br></br> <br></br> <apex:repeat var="RL" value="{!ResourceList}"> <table border="1" style="width:100%" > <tr> <th >Name</th> </tr> <tr> <td>{!RL.Account__r.Name}</td> </tr> <tr> <th>Description</th> </tr> <tr> <td>{!RL.Account__r.Description}</td> </tr> <tr> <th>Address</th> </tr> <tr> <td>{!RL.Account__r.BillingStreet}<br></br> {!RL.Account__r.BillingCity}, {!RL.Account__r.BillingState} {!RL.Account__r.BillingPostalCode} </td> </tr> </table> <table border="1" style="Width:100%"> <tr> <th>Phone</th><th>Type</th><th>Distance</th> </tr> <tr> <td>{!RL.Account__r.Phone}</td><td>{!RL.Type__c}</td><td>{!RL.Distance__c} miles</td> </tr> </table> <br></br> <br></br> <br></br> <br></br> <br></br> </Apex:Repeat> </apex:form> </apex:page>Controller
public class ResourceListController { public Id RecordId {get;set;} public List<Resource_List__c> getResourceList() { RecordId = ApexPages.currentPage().getParameters().get('id'); List<Resource_List__c> results = Database.query( 'SELECT Id, Account__c, Account__r.Name, Distance__c, type__c, Account__r.Phone, Account__r.Description, Account__r.billingStreet, Account__r.billingCity, Account__r.billingPostalCode, Account__r.billingState ' + 'FROM Resource_List__c ' + 'Where Social_Services_Assessment__c = :RecordId' + 'ORDER BY Type__c asc, Distance__c asc' ); return results; } }Test Class
@isTest public class resourceListTestClass { static testMethod void testMethod1() { Account ta = new Account(); ta.name = 'Alex Demo'; ta.First_Name__c = 'Alex'; ta.Surname__c = 'Demo'; ta.Primary_Insurance__c = 'Test Insurance Company'; ta.Gender__c ='Male'; ta.County__c ='Yavapai'; ta.BillingStreet = '123 West Gurley Street'; ta.BillingCity = 'Prescott'; ta.BillingState = 'Arizona'; ta.BillingPostalCode = '86303'; ta.RecordTypeId = '012360000004FEPAA2'; insert ta; Social_Services_Assesment__c sw = new Social_Services_Assesment__c (); sw.Account__c = ta.Id; sw.Radius_in_miles__c = 25; sw.Monthly_income__c = 5000; sw.Do_you_have_enough_money_each_month__c = 'No'; sw.Do_you_recieve_SSI__c = 'No'; sw.Do_you_receive_SSDI__c = 'No'; sw.Do_you_receive_food_assistance__c = 'No'; sw.Do_you_receive_cash_assistance__c = 'No'; sw.Do_you_have_adequate_shelter__c = 'No'; sw.Do_you_need_congregate_meals__c = 'Yes'; sw.Do_you_need_transportation__c = 'Yes'; sw.Do_you_have_enough_money_each_month__c = 'No'; sw.Can_you_pay_for_your_housing__c = 'No'; sw.Can_you_pay_your_utilities__c = 'No'; sw.Can_you_pay_for_transportation__c = 'No'; sw.Can_you_pay_for_medical_visits__c = 'No'; sw.Are_you_unemployed__c = 'Yes'; sw.SSI_SSDI_decreased__c = 'Yes'; sw.RecordTypeId = '0121R000000yZUyQAM'; insert sw; Account r1 = new Account (); r1.RecordTypeId = '0121R000000yZGLQA2'; r1.Name = 'Resource 1'; r1.Food_Bank__c = true; r1.Financial_Assistance__c = true; insert r1; Account r2 = new Account (); r2.RecordTypeId = '0121R000000yZGLQA2'; r2.Name = 'Resource 2'; r2.Food_Bank__c = true; r2.Financial_Assistance__c = true; insert r2; Resource_List__c RL1 = new Resource_List__c (); RL1.Account__c = r1.Id; RL1.Social_Services_Assessment__c = sw.id; insert RL1; Resource_List__c RL2 = new Resource_List__c (); RL2.Account__c = r2.Id; RL2.Social_Services_Assessment__c = sw.id; insert RL2; Test.StartTest(); PageReference PageRef = Page.ResourceList; Test.setCurrentpage(PageRef); System.currentPageReference().getParameters().put('RecordId',sw.Id); ResourceListController controller = new ResourceListController(); Test.StopTest(); } }
- Alex Waddell 18
- May 14, 2020
- Like
- 0
Pass Record Id into Visual Force page
I am learning Apex and am trying to get my controller to query for Resource_List__c records where the Survey_Form__c field = :RecordId (the current Survery_Form__c record I am viewing)
VF Page
Class
VF Page Output when on the Lightning page
but when I put the query into the query editor and hard code the record Id there are values in this table
Is there any way to pass the record id into the VF page without invoking aura or LWC? I just want to learn the fundamentals before I step into those new languages
VF Page
<apex:page Controller="ResourceListController"> <apex:form> <apex:pageBlock> <apex:pageBlockTable value="{! ResourceList }" var="RL"> <apex:column value="{! RL.Id }"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Class
public class ResourceListController { public Id RecordId {get;set;} public List<Resource_List__c> getResourceList() { List<Resource_List__c> results = Database.query( 'SELECT Id, Account__c, Distance__c, type__c ' + 'FROM Resource_List__c ' + 'Where Survey_Form__c = :RecordId ' ); return results; } }
VF Page Output when on the Lightning page
but when I put the query into the query editor and hard code the record Id there are values in this table
Is there any way to pass the record id into the VF page without invoking aura or LWC? I just want to learn the fundamentals before I step into those new languages
- Alex Waddell 18
- March 17, 2020
- Like
- 0
Running into SOQL Query limit 101 when importing data using data loader
I am running into an error when mass creating assessments using dataloader.
I have a feeling that I running 3 queries inside of the For() is the cause of my issue. Can someone help me rework this code to avoid these issues moving forward?
I have a feeling that I running 3 queries inside of the For() is the cause of my issue. Can someone help me rework this code to avoid these issues moving forward?
trigger closeCaseOnIcmDischarge on Patient_Ass__c (After insert) { for(Patient_ass__c pAss : trigger.new){ Patient_Assessment_View__c pView = [Select id,Account__c From Patient_Assessment_View__C Where id = :pAss.Patient_Assessment_View__c]; List <Case> c = [Select id, Discharge_Reason__c, Discharge_Date__c, Accountid From Case Where status IN('New','On Service') AND RecordTypeId = '01236000000OJLq' And Accountid = :Pview.Account__c Limit 1]; List <TeleWell_Care_Plan__c> TW = [Select id,Use_Question_1__c From Telewell_Care_Plan__c Where Patient_Assessment_and_Care_Plan__c = :Pview.id LIMIT 1] ; if(c.size() > 0 && pAss.RecordTypeId == '01236000000nufHAAQ'){ c.get(0).status ='Closed'; c.get(0).Discharge_Reason__c = pAss.Discharge_Reason__c; c.get(0).Discharge_Date__c = System.today(); Update c; TW.get(0).Use_question_1__c = 'No'; Update TW; } Else{ } } }
- Alex Waddell 18
- December 17, 2019
- Like
- 0