
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.
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.
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();
});
Hi Ryan,
Is this javascript still active in version 8.3.0.6? I am trying to modify the speedsearch lookup in SpeedSearchLookup.js for participants (add columns, increase width) and nothing I do to has any affect.
Steve
Hi Steve,
I’ve not tested it specifically in 8.3.0.6, but I have customers with this code in place that are on that version, so I expect it still works there. This article is pretty specific for the attendees lookup on the activity dialog, it might be different for other lookups.
Maybe refer to these, they might get you in the right direction:
Making Columns Resizable in the Lookup Dialog in Infor CRM Web
https://customerfx.com/article/making-columns-resizable-in-the-lookup-dialog-in-infor-crm-web/
Setting a Default Search Field and Search Operator for Lookups in Infor CRM
https://customerfx.com/article/setting-a-default-search-field-and-search-operator-for-lookups-in-infor-crm/
However, I’ve never modified that for Speedsearch, that is likely quite different than a standard lookup.
Ryan