• Vivi Pio
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I'm trying to build a lightning component based on the Trailhead Contacts Nearby project, except using Accounts instead.  I'm getting the following error screen when I try to drag it to a Lightning Page:

User-added image


Controller: 
public with sharing class AcctController {

    @AuraEnabled
    public static List<Account> findNearby(Double latitude, Double longitude, Double maxDistance) {
        return Database.query('SELECT Id, Name, BillingStreet, BillingCity, BillingState, Next_Contract_Expiration__c, Current_Contract_Volume__c, Phone FROM Account' +
                       ' WHERE DISTANCE(Location__c, GEOLOCATION(' + latitude + ',' + longitude + '), \'mi\') < '+ maxDistance +
                       ' ORDER BY DISTANCE(Location__c, GEOLOCATION(' + latitude + ',' + longitude + '), \'mi\')');
        
    }

}

Component:
<aura:component controller="AcctController" implements="flexipage:availableForAllPageTypes">

    <aura:attribute name="maxDistance" type="integer"/>
    <aura:attribute name="latitude" type="Decimal"/>
    <aura:attribute name="longitude" type="Decimal"/>
    <aura:attribute name="Account" type="Account[]"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

    <div>
        <h2>Accounts Nearby</h2>
        <ul>
            <aura:iteration items="{!v.Account}" var="Account">
                <li>
                    <h3><a href="{! '#/sObject/' + Account.Id + '/view'}">{!Account.Name}</a></h3>
                    <aura:if isTrue="{! Account.BillingCity}">
                        <p><a href="{! 'http://maps.apple.com?q=' + Account.BillingStreet + ', ' + Account.BillingCity}">
                            {!Account.BillingStreet}<br/>
                            {!Account.BillingCity}, {!Account.BillingState}<br/>
                            {!Account.Current_Contract_Volume__c} + '  ' + {!Account.Next_Contract_Expiration__c}</a></p>
                    </aura:if>
                    <p><a href="{! 'tel:' + Account.phone}">{!Account.Phone}</a></p>
                </li>
            </aura:iteration>
        </ul>
    </div>

</aura:component>

The code is basically the same as the ContactsNearby, which appropriate changes made to desired fields and object, and it does not give off any code errors when saving, so syntax must be somewhat acceptable.  Any thoughts?