In my previous blog, I described how to set up a service in Creatio to retrieve a set of locations from a specified radius around a given location. Once this data service has been set up, the next step is to integrate its data onto the AccountAddressPageV2 so Creatio can handle multiple map locations.

To modify Creatio’s account address page to use our additional mapping data, we must start with the OnEntityInitialized method. This method will be kicked off as soon as the page loads for a selected address. It will call the base code and any additional methods to get the necessary mapping data and transform it into a format that is compatible with the Creatio mapping functionality. We must set up several methods to accomplish this. I’ve documented that process below.

Step 1: Set up a Replacing Module

The first thing we need to do is set up a replacing module specifically for the AccountAddressPageV2 module. This will create a new “Replacing view model” module where we can implement all our code enhancements.

replacing view module Creatio

Step 2: Set up Necessary Attributes

To temporarily store the contents of the location data we retrieved, we must define an attribute that will house the data. An attribute can be a number, text, or in our case a “Custom Object” because this attribute allows the storage of more complex data structures. In this case, we will have several address records, and each will have several columns. So, we will define an attribute named “NearbyLocations” which is of type “CUSTOM_OBJECT”.

nearby locations attribute Creatio

Step 3: Set up Supporting Code

onEntityInitialized method

Update this method to call the base functionality and also add the call to the getNearbyLocations method to perform the retrieval of address locations from our data service.

Creatio entity initialized method

getNearbyLocations method

This method communicates with the service named “NearbyLocationsService”. It gets the location data within a radius and combines all the information so it can be stored in the “NearbyLocations” attribute mentioned earlier.

Creatio get nearby locations method

getMapsConfig method

The getMapsConfig method is a method that supplies the necessary information for the address mapping function to operate and enable the plotting of locations. Because we have our location data stored in the “NearbyLocations” attribute, this method plays middle man and pulls the data from the NearbyLocations attribute and then supplies it as a data array for use by the Creatio map plotting functionality.

Creatio get maps config method

changeLocation method

This is a base method that informs the mapping functionality that location data has changed and that new data should be used when plotting locations on a map.

change location method creatio

updateMap method

This method is a base method that must be updated so any previous location data is cleared out before new data is retrieved.

Creatio update map method

Once these methods are set up, the page should be able to retrieve, maintain, and supply the necessary data to the mapping module (named “OsmMapsModule”). 

Obviously, there’s more that can be done if you need the page to trigger the mapping operation via a button or need to implement additional location selection logic. If you haven’t already, you might find this article on how to make changes to the OsmMapsModule component in Creatio helpful.

Posted in:

Looking for Creatio help?

We do training, customization, integration, and much more. Contact us today.