Retrieve Data That Salesforce Maps Hosts

The GetHostedData() Apex method retrieves geographical IDs for properties and displays them in Salesforce Maps. We accomplish this retrieval in two requests while using the same method. The first request returns geographical IDs for properties that Salesforce Maps hosts for a specified area and filter criteria. The second request takes these geographical IDs and display parameters, such as legend and popup information, and displays them in Salesforce Maps.

Salesforce Maps works with data providers that supply property and business data. Periodically, these providers update their data, which can affect custom code. If the providers change their data formats, update your custom code accordingly. Salesforce Maps can update, replace, or remove property data at any time.

Where,

  • maps is the namespace that’s available after you install Salesforce Maps.
  • API is the class that contains the global methods exposed to developers.
  • GetHostedData() is the method.

The first example request using the GetHostedData() method returns geographical IDs for women-owned businesses that Salesforce Maps host. Those businesses produce revenue between $100,000 and $1,000,000 in a specified area.

If you invoke methods within a flow, process builder, or trigger, avoid uncommitted work errors when you perform one of the following.

  • Call the methods through a future method
  • Call the methods as queueable

Uncommitted work errors can also arise if calling out to Salesforce Maps methods more than one time in a single transaction and the Salesforce Maps token hasn’t refreshed in the last 24 hours. If these errors occur, separate each callout into individual transactions.

Different processes refresh the token, such as plotting a route or schedule. The refresh process is almost immediate after each qualifying action occurs.

Input Format of the Parameters

Example

Although the return value is an Apex Map<String, Object> object, this JSON response illustrates the essential data you receive in the resulting map.

The second request using the GetHostedData() method takes the geographical IDs and display parameters, such as legend and popup information, and displays them in Salesforce Maps.

Input Format of the Parameters

Example

Although the return value is an Apex Map<String, Object> object, this JSON response illustrates the essential data you receive in the resulting map.