Show map on contact record

Hello all,

 

I am trying to use the show on map function from the contact section page and add it to the actions on the contact record page.

I have added the function to the page schema and added it to the actions menu. However, when I load the page, the button works and displays the map but it doesn't display the caption string on the button. 

Though oddly, when I reload the page, the string appears but the map then won't load.

 

What could be causing this?

Like 0

Like

1 comments

Hello Kevin,

 

Caption is not displayed since once the edit page is reviewed in combined mode then localizable values are being received from the section schema. To resolve this problem you need to:

 

1) Add the same localizable value to the ContactSectionV2 schema as on the ContactPageV2 schema

2) Add this part of code to the contact page schema:

 

define("ContactPageV2",["ContactPageV2Resources", "MapsHelper", "MapsUtilities"],

        function(resources, MapsHelper, MapsUtilities){

    return{

        entitySchemaName:"Contact",

        modules:/**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,

        messages: {

            "GetMapsConfig": {

                mode: Terrasoft.MessageMode.PTP,

                direction: Terrasoft.MessageDirectionType.SUBSCRIBE

            }

        },

        businessRules:/**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,

        methods:{

            getActions: function() {

                var actionMenuItems = this.callParent(arguments);

                actionMenuItems.addItem(this.getButtonMenuItem({

                    "Tag": "showOnMap",

                    "Click": {"bindTo": "openShowOnMap"},

                    "Caption": {"bindTo": "Resources.Strings.ShowOnMapCaption"},

                    "Visible": true

                }));

            

                return actionMenuItems;

            },

            showOnMap: function(schemaName, items, callback) {

                var config = config || {};

                items = items || this.getesqedItems();

                var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {

                    rootSchemaName: "ContactAddress"

                });

                esq.addColumn(schemaName + ".Name");

                esq.addColumn("AddressType");

                esq.addColumn("Address");

                esq.addColumn("City");

                esq.addColumn("Region");

                esq.addColumn("Country");

                if(config.columnNameLongitude){

                    esq.addColumn(config.columnNameLongitude);

                }

                if(config.columnNameLatitude){

                    esq.addColumn(config.columnNameLatitude);

                }

                esq.filters.addItem(this.Terrasoft.createColumnInFilterWithParameters(schemaName, items));

                esq.getEntityCollection(function(result) {

                    var addresses = result.collection;

                    if (result.success && !addresses.isEmpty()) {

                        var mapsData = [];

                        var mapsConfig = {

                            mapsData: mapsData

                        };

                        addresses.each(function(item) {

                            var addressType = item.get("AddressType").displayValue;

                            var address = MapsHelper.getFullAddress.call(item);

                            var content = this.Ext.String.format("<h2>{0}</h2><div>{1}</div>", addressType, address);

                            var dataItem = {

                                caption: addressType,

                                content: content,

                                address: address,

                                gpsE: item.get(config.columnNameLongitude),

                                gpsN: item.get(config.columnNameLatitude)

                            };

                            mapsData.push(dataItem);

                        }, this);

                        callback.call(this, mapsConfig);

                    } else {

                        this.showInformationDialog(resources.localizableStrings.EmptyAddressDetailMessage);

                    }

                }, this);

            },

            openShowOnMap: function() {

                var items = [];

                items.push(this.get("Id"));

                this.showOnMap.call(this, this.entitySchemaName, items, function(mapsConfig) {

                    MapsUtilities.open({

                        scope: this,

                        mapsConfig: mapsConfig

                    });

                });

            }

}

 

3) Add the EmptyAddressDetailMessage localizable string to the ContactPageV2 schema

 

Best regards,

Oscar

Show all comments