Adding a Filter/Condition to the Contact Attendees Lookup in the Infor CRM Activity Editor Dialog

I’ve posted a few times before about customizing the Infor CRM (Saleslogix) Activity Editor Dialog. It’s a form made up of 100% Javascript so customizing it isn’t like your typical Infor CRM Web customizations. In this article, we’ll be looking at how to customize the lookup to add contact attendees (participants) to the activity. Specifically, we’ll be adding a condition to filter that lookup by the contact’s title, allowing only contacts with a particular title to be added as attendees.

Before we look at the code, I will be using my Custom Script 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 Script 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. Inside the Custom/Modules folder, let’s create a new folder named “ActivityAttendees”. Inside this new folder, add a new text file and name it main.js. We’ll be adding this code inside that folder.

define([
    'dojo/_base/declare',
    'dojo/_base/lang',
    'Sage/MainView/ActivityMgr/ActivityEditor'
], 
function (declare, lang, ActivityEditor) {
     
    function initializeActivityAttendees() {
     
        lang.extend(Sage.MainView.ActivityMgr.ActivityEditorAttendeesTab, {
	
            lookupContacts: function () {
                this.lup_Contact.seedProperty = 'Account.Id',
                this.lup_Contact.seedValue = this.actEditor._activityData.AccountId;

                // This is the line we are changing to add our condition to the lookup.
                // In this sample code, we're adding a condition to only allow adding 
                // contacts with a title of "President" or "Owner".
                this.lup_Contact.query.conditions = 'Title in ("President", "Owner")';
 	
                this.lup_Contact.buildSDataStoreQueryForSeeding();
                this.lup_Contact._originalQueryConditions = this.lup_Contact.query.conditions;
                this.lup_Contact.cancelText = this.lup_Contact.closeText;
                this.lup_Contact.overrideSeedValueOnSearch = true;
                this.lup_Contact.showLookup();
                var handle = dojo.connect(this.lup_Contact.lookupDialog, 'onHide', this.lup_Contact, function () {
                    dojo.disconnect(handle);
                    if (this.seedValue) {
                        this.resetGrid();
                    }
                });
            }
 
        });
        
    }
     
    // run customizations 
    initializeActivityAttendees();
});

So what exactly are we doing here? If we look in the code that makes up the Attendees (participants) tab, located in jscript/Sage/MainView/ActivityMgr/ActivityEditorAttendeesTab.js, you’ll see a function named lookupContacts on line 472. This is the code that fires when you click on the button to lookup (or add) a contact attendee to the activity. We’re overriding (replacing) that entire function with our own so that we can set the condition for the lookup (if the out of the box code didn’t specifically set the condition for the lookup to empty on line 475, we could have just done an aspect.before to add that without needing to replace the entire function. Once we’ are replacing that function, we can do whatever we want there. In the sample code above we’re just setting the condition to filter the lookup to only show contacts with a title of “President” or “Owner”. In the end, this article isn’t so much about how to restrict that lookup, but more about showing how to customize the areas of the activity editor by overriding functions with your own.

ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix since 2001 and believes in sharing with the community. He loves C#, Javascript, Python, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

2 Comments

  1. Good Afternoon, I have a problem with a customization of activity, I try to replace the Category picklist, and I need to hide this field and show the new Category Lookup.

    When I use this instruction this.pk_Category.set(‘readonly’, true); or this.pk_Category.set(‘visible’, false); the aplication doesn’t work, I use these instruction in the custom module.

    This is the code:

    define([
    ‘dojo/ready’,
    ‘dojo/_base/declare’,
    ‘dojo/aspect’,
    ‘dojo/_base/lang’,
    ‘Sage/MainView/ActivityMgr/ActivityEditor’,
    ‘Sage/MainView/ActivityMgr/HistoryEditor’,
    ‘Sage/Services/ActivityService’,
    ‘Sage/UI/Controls/Lookup’
    ],
    function (ready, declare, aspect, lang,
    ActivityEditor, HistoryEditor, ActivityService, Lookup) {

    function initializeActivityEditor()
    {

    this.pk_Category.set(‘visible’, false);
    }
    initializeActivityEditor();
    //}
    });

    Please, I need your help.

    Regards.

    Reply
    • Iveth,

      When your script is getting executed the dialog doesn’t even exist yet so there is no category control to hide. You need to add code so you are attempting to hide it in an event on the ActivityEditor dialog after it has been created already such as _manualBind or postCreate. Try something like this instead:

      define([
      ‘dojo/_base/declare’,
      ‘dojo/_base/lang’,
      ‘Sage/MainView/ActivityMgr/ActivityEditor’
      ],
      function (declare, lang, ActivityEditor) {

      function initializeActivityCustomizations() {

      lang.extend(Sage.MainView.ActivityMgr.ActivityEditor, {

      postCreate: function () {
      Sage.MainView.ActivityMgr.ActivityEditor.superclass.postCreate.apply(this, arguments);
      // add custom code here
      }

      });

      }

      // run customizations
      initializeActivityCustomizations();
      });

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) news and product updates!

You have Successfully Subscribed!