Customizing the Activity Dialog in Infor CRM to Default the Activity Location to the Selected Contact’s Address

Customizing the Activity Dialog in Infor CRM Web is not like customizing other forms. This form is not a QuickForm/SmartPart or ASP.NET form. Instead, it is made entirely of Javascript. However, once you’ve learned the basics of how to work with it, you actually have every bit as much flexibility, or more, than working with a traditional QuickForm. In this article, we will look at how to add a simple customization to default an activity’s location to the selected contact’s address.

Before we look at the code, I will be using my Custom Loader Module that I have blogged about previously. Visit the link below, download the bundle and install it. The module that bundle installs allows us to simply drop a Javascript file into a folder without the need to wire it up in the master page.

Get the Custom Loader Module
Note: There’s a link to the bundle at the bottom of the page when you follow this link. Just install the bundle and you’re set.

Once the Custom Script Loader Module is installed, if you look in the SlxClient portal in AA, under SupportFiles, you’ll see a new folder named Custom. Inside that folder there is a folder named Modules. We’re going to be placing our custom code there. For customizing the ActivityDialog, there’s a few different ways that can be done. You’ll typically see that done via an inheritance-like way where you override a method. We’re going to be using one of my favorite methods, using Dojo’s aspect module. Aspect lets you piggyback before, after, or around another method in another class. We’re going to create a method that runs after the _contactChanged function in the ActivityDialog runs (which fires after a contact is set for the activity). We’re basically attaching more code that runs after the code in that method runs, like an extension of that function.

Under the SupportFiles\Custom\Modules folder, create a new folder named ActivityLocation. Then, inside that folder, create a new text file named “main.js” and paste in the code below:

function (declare, lang, aspect, SDataServiceRegistry, ActivityEditor) {
    function initializeActivityEditor() {
        aspect.after(ActivityEditor.prototype, '_contactChanged', function(contact) {
            // Uncomment these lines if you want to default the location for
            // Meetings only. Otherwise will default for all activity types
            //if (this.activityType != 'atAppointment')
            //    return;
            // if contact cleared, clear location
            if (!contact || !contact['$key']) {
                Sage.Utility.setValue(this._activityData, 'Location', '');
                this.tb_Location.set('value', '');
            // get address data for contact
            var req = new Sage.SData.Client.SDataSingleResourceRequest(SDataServiceRegistry.getSDataService('dynamic'))
                .setResourceSelector('"' + contact['$key'] + '"')
                .setQueryArg('include', 'Address')
                .setQueryArg('select', ['Address/Address1','Address/Address2','Address/City','Address/State','Address/PostalCode','Address/Country'])
                success: function (data) {
                    var address = lang.getObject('Address', null, data);
                    if (!address)
                    var address1 = address.Address1,
                        address2 = address.Address2,
                        city = address.City,
                        state = address.State,
                        zip = address.PostalCode,
                        country = address.Country,
                        location = '';
                    if (address1 && address1.trim() != '')
                        location = address1;
                    if (address2 && address2.trim() != '')
                        location += ', ' + address2;
                    if (city && city.trim() != '')
                        location += ' ' + city;
                    if (state && state.trim() != '')
                        location += ', ' + state;
                    if (zip && zip.trim() != '')
                        location += ' ' + zip;
                    if (country && country.trim() != '')
                        location += ' ' + country;
                    // set location
                    if (location.trim() != '')
                        Sage.Utility.setValue(this._activityData, 'Location', location);
                        this.tb_Location.set('value', location);
                scope: this
        }, true);
    // run customizations 

That’s it (well, also a build & deploy). Now, when you open the activity dialog, any time a contact is selected (including if it is populated from the current record, etc), it will set the activity location to the contact’s address.


Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!