No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Address Class
Namespace
Usage
Each of these methods is also equivalent to a read-only property. For each getter method, you can access the property using dot notation. For example, myAddress.getCity() is equivalent to myAddress.city.
You can’t use dot notation to access compound fields’ subfields directly on the parent field. Instead, assign the parent field to a variable of type Address, and then access its components. For example, to access the City field in myAccount.BillingAddress, do the following:
1Address addr = myAccount.BillingAddress;
2String acctCity = addr.City;Example
1swfobject.registerObject("clippy.codeblock-1", "9");// Select and access Address fields.
2// Call the getDistance() method in different ways.
3Account[] records = [SELECT id, BillingAddress FROM Account LIMIT 10];
4for(Account acct : records) {
5 Address addr = acct.BillingAddress;
6 Double lat = addr.latitude;
7 Double lon = addr.longitude;
8 Location loc1 = Location.newInstance(30.1944,-97.6682);
9 Double apexDist1 = addr.getDistance(loc1, 'mi');
10 Double apexDist2 = loc1.getDistance(addr, 'mi');
11 System.assertEquals(apexDist1, apexDist2);
12 Double apexDist3 = Location.getDistance(addr, loc1, 'mi');
13 System.assertEquals(apexDist2, apexDist3);
14}Address Methods
The following are methods for Address.
getCountryCode()
Returns the country code of this address if state and country
picklists are enabled in your organization. Otherwise, returns null.
Signature
public String getCountryCode()
Return Value
Type: String
getDistance(Location, String)
Signature
public Double getDistance(Location toLocation, String units)
Parameters
Return Value
Type: Double
getStateCode()
Returns the state code of this address if state and country picklists
are enabled in your organization. Otherwise, returns null.
Signature
public String getStateCode()
Return Value
Type: String