Geopointe

Custom Map Object – Salesforce Integration

Nice work! You’ve successfully set up a custom object for use in Geopointe. Now we want to make the custom object experience just as fluid as it is with a standard object. This document walks through the same steps as the standard integration document, but is specific to custom objects. This doc includes directions to:

Creating a Custom Object Map Button

If you use the Map button on your standard object records, you will want the same experience on your custom objects as well. They are two options for how to build it. Option 1 is a simple URL, and will work in the majority of orgs. It is also easier if you intend to include additional URL parameters. Option 2 allows for a more dynamic URL, necessary for some console or community environments, but also works for standard Salesforce environments.

Option 1 - Simple URL

Follow these steps to create your custom Map button. Remember, Option 1 will work with most orgs, and is easiest to work with if you plan to include additional URL parameters.

1. In Salesforce Setup, use the Quick Find search to navigate Objects. In Lightning, navigate to the Object Manager instead. 

2. Click the custom object you want to add the button to (Note: Do not click Edit). Scroll to/select Buttons, Links, and Actions then click New Button or Link (In Lightning, this section is found in the left menu, not by scrolling down the page).

3. Add a Label (typically we use "Map") and allow the Name field to auto-populate. 

4. Set the Display Type to Detail Page Button, and choose a Display Behavior (either in an existing window or a new window; in Lightning, the behavior is identical). The settings should look like this:

5. Copy/paste the code below into the editor field. Change Object_Name__c to the object’s API Name.

/apex/geopointe__Map?id={!Object_Name__c.Id}

For example, a custom object with the API name of Hospital__c will use the following code:
/apex/geopointe__Map?id={!Hospital__c.Id}. 

5. Check for syntax errors, then click Save. The button is now ready to be added to a page layout. This button works in both the Lightning and Classic interfaces.
 

Option 2 - Dynamic URL

Follow these steps to create your custom Map button. The Dynamic URL works for all environments, but would be your preferred choice if you are wanting to add it to communities or consoles.

1. In Salesforce Setup, use the Quick Find search to navigate Objects. In Lightning, navigate to the Object Manager instead. 

2. Click the custom object you want to add the button to (Note: Do not click Edit). Scroll to/select Buttons, Links, and Actions then click New Button or Link (In Lightning, this section is found in the left menu, not by scrolling down the page).

3. Add a Label (typically we use "Map") and allow the Name field to auto-populate. 

4. Set the Display Type to Detail Page Button, and choose a Display Behavior (either in an existing window or a new window; in Lightning, the behavior is identical). The settings should look like this:

5. Copy/paste the code below into the editor field. Change Object_Name__c to the object’s API Name.

{!URLFOR($Site.Prefix+'/apex/geopointe__Map?id='+Object_Name__c.Id)}

For example, a custom object with the API name of Hospital__c will use the following code:
{!URLFOR($Site.Prefix+'/apex/geopointe__Map?id='+Hospital__c.Id)}. 

5. Check for syntax errors then click Save. The button is now ready to be added to a page layout. This button works in both the Lightning and Classic interfaces.

Creating a Custom Object Map Records Button

The Map Records button allows you to be on a list view, select records, and then see those selected records on the map. You can create this button to work on all custom objects that you have mapped in Geopointe.

There are two ways to build this button. The older way (only supported with Salesforce Classic), requires some javascript in a button. The newer option requires the creation of a Visualforce page, but works in both Classic and Lightning. Choose the one that best meets your needs. Don't worry! You don't need to be a coder to complete these steps.

Option 1 - VisualForce Button

Follow these steps to create your custom Map Records button. The Visualforce button does work in both Salesforce Classic and Lightning, but requires the creation of a Visualforce page.

1. In Salesforce Setup, use the Quick Find or navigate to Visualforce Pages. Click New.

2. Give the VF page a name/label that will make it easily recognizable. We'd recommend the same format as our packaged pages, for example: MapRecordsProperties.

3. Enter the code below into the Visualforce Markup text area. Change Object_Name__c to the object’s API Name.

<apex:page label="Map Records" standardController="Object_Name__c" recordSetVar="records" action="{!mapRecords}" extensions="geopointe.MapRecordsExtension">
    <apex:pageMessages id="pageMessageError"/>
</apex:page>

4. When finished, click Save.

5. Still in Salesforce Setup, use the Quick Find search to navigate Objects. In Lightning, navigate to the Object Manager instead. Click the custom object you want to add the button to. Scroll to/select Buttons, Links, and Actions then click New Button or Link (In Lightning, this section is found in the left menu, not by scrolling down the page).

6. Add a Label (typically we use "Map Records") and allow the Name field to auto-populate. 

7. Set Display Type as Detail Page Link. Set the Behavior to Display in existing window without sidebar

8. Set Content Source to Visualforce Page. After it's been selected, the textarea will disappear and you can choose a Content source instead. Select the Visualforce Page you just created and Save.

This button is now ready to be added to your list views!
 

Option 2 - Javascript Button

Follow these steps to create your custom Map Records button. The button only works in Salesforce Classic, but does require few steps than the option above.

1. In Salesforce Setup, use the Quick Find search to navigate Objects. In Lightning, navigate to the Object Manager instead. Click the custom object you want to add the button to. Scroll to/select Buttons, Links, and Actions then click New Button or Link (In Lightning, this section is found in the left menu, not by scrolling down the page).

2. Add a Label (typically we use "Map Records") and allow the Name field to auto-populate. 

2. Set the Display Type as List Button. Set Behavior to Execute Javascript

4. Enter the below code into the editor field. Change Object_Name__c to the API Name of the appropriate object.

// Get data array
idArray = {!GETRECORDIDS($ObjectType.Object_Name__c)};
// Submit URL
f=document.createElement('form');
f.target = '_blank';f.action='/apex/geopointe__Map';
f.method = 'get';
i= document.createElement('input');
i.id = 'idArray';
i.name = 'idArray';
i.type = 'hidden';
i.value = idArray;
f.appendChild(i);document.body.appendChild(f);f.submit();

5. Check your syntax and click Save.

This button will now be available for you to add to list views!

If you have any questions or run into problems created any of these buttons, log a support case and we'll be happy to help!