You need to sign in to do that
Don't have an account?
Michael Hedrick 2
Unknown Constructor error in VF Page
Hello everyone;
I thought I had this right but I am not refencing the Class correctly in my VF page. What I am trying to do is show a list of accoutns around a lead record based on the geo location.
error: Error: Unknown constructor 'LeadGeoController.LeadGeoController(ApexPages.StandardController controller)
M
I thought I had this right but I am not refencing the Class correctly in my VF page. What I am trying to do is show a list of accoutns around a lead record based on the geo location.
error: Error: Unknown constructor 'LeadGeoController.LeadGeoController(ApexPages.StandardController controller)
<apex:page standardstylesheets="true" showheader="false" standardController="Lead" extensions="LeadGeoController"> <apex:pageBlock title="Recent Orders for Lead"> <apex:pageBlockTable styleClass="responsive-table" value="{!GetAccountsNearLead}" var="accounts"> <apex:column title="Account Name " value="{!account.name}" headerValue="Name"/> <apex:column title="Contacts Email Address " value="{!account.Primary_Contact_Email_Address__c}" headerValue="Email Address"/> <apex:column title="Account Street Address " value="{!account.BillingStreet}" headerValue="Address"/> <apex:column title="Account City " value="{!account.BillingCity}" headerValue="City"/> <apex:column title="Diectance From Lead " value="{!account.Distance}" headerValue="Distance"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>
public with sharing class LeadGeoController { public Decimal lat { get; set; } public Decimal longitude{ get; set; } public LeadGeoController () { List<Lead> lat = [SELECT MALatitude__c from Lead WHERE Id=:ApexPages.currentPage().getParameters().get('id')]; List<Lead> longituide= [SELECT MALongitude__c from Lead WHERE Id=:ApexPages.currentPage().getParameters().get('id')]; } public List<Account> GetAccountsNearLead() { return [SELECT Name, Primary_Contact_Email_Address__c,BillingStreet,BillingCity,distance(BillingAddress, geolocation(:lat , :longitude), 'mi') Distance FROM Account WHERE Partner_Type__c= 'TrexPro' AND distance(BillingAddress, geolocation(:lat , :longitude), 'mi') < 10 // AND Id = :ApexPages.currentPage().getParameters().get('id') ORDER BY distance(BillingAddress, geolocation(:lat , :longitude), 'mi') LIMIT 5]; } }Thanks,
M
public LeadGeoController (ApexPages.StandardController stdController)
When you use StandardController you need to pass ApexPages.StandardController as an arg to the constructor .
I totally forgot that piece.
So now I get this error on the Vf page: Thanks for all of your help.
Hello,
You should use <apex:repeat > to iterate list of account, Here the code
Thank you
I am getting the follow error:
Missing required attribute value in <apex:pageBlockTable> in LeadGeoController
Do I need to remove the pageBlockTable? Do the Apexd Class also need to be edited?
Thank you for your time.
M
I hope , it will help you
Thank you
Very close. The VF page does not recognize 'Distance' as a SObject field.
The distance value is part of the Geolocation function and does not exist in Salesforce as a field.
Thanks,
M
Even If I hardcode the Lat and Long:
lat = 39.14 ;
longitude = -78.17
Is the SOQL statement not pulling in the Lat and Long values?
Thanks