Customizing the Account Associations SData Grid in Infor CRM (Saleslogix)

The Account Associations tab in Infor CRM is made of a custom SmartPart that contains an SData DataGrid. Usually, when working with an SData Grid in Application Architect, you have editors that help you set up the columns and elements of the grid. However, since this is a custom SmartPart, you’ll need to edit the Javascript directly.

To locate the Account Associations tab, you’ll need to open the SlxClient portal in AA under the Portal Manager, then on the Support Files tab, expand, SmartParts and then the Association folder. Double-click to open the “AccountAssociations.js” file.

In this example, we’ll be adding the City, State, & Zip to the grid layout.

Adding Address Fields to the Associations Grid

First, we’ll need to add the fields we’d like to add to the list of fields that are being retrieved via SData. You’ll find that on line 83, where it shows “select” under the “storeOptions”. These are the fields being retrieved via SData. For our example, we’ll be adding the Address.CityStatePostalCode calculated field to be retrieved, and since there are two sides to the association, we’ll need to retrieve that for the ToAccount and also the FromAccount. The code for that section will look like this:

storeOptions: {
    resourceKind: 'associations',
    include: [],
    select: ["FromId", "ToId", "ToAccount.AccountName", "BackNotes", "BackRelation", "IsAccountAssociation", "ToAccount.Address.CityStatePostal", "FromAccount.Address.CityStatePostal"],
    dataCarrierId: 'AccountAssociationsgrdAssociations_DataCarrier',
    sort: []
},

Notice the “ToAccount.Address.CityStatePostal”, “FromAccount.Address.CityStatePostal” at the end of the select line.

Now, we need to add the field to the layout. That is done just above, in the “columns” section (which starts at line 68). We’ll add a new line and specify the field the column is bound to, the name (heading/caption), and other special rules for our column. It will look like this:

columns: [
    { 
        name: ' ', field: 'Id', width: 5, type: slxEdit, cellValue: AccountAssociationsResource.AccountAssociationsGrid_Edit_Text,
        entityType: 'Sage.Entity.Interfaces.IAssociation, Sage.Entity.Interfaces', smartPart: 'AddEditAccountAssociation',
        isCentered: true, dialogHeight: 320, dialogWidth: 600, formObjectName: 'Sage.UI.Forms.AccountAssociations'
    },
    { field: "FromAccount.AccountName", name: AccountAssociationsResource.AccountAssociationsGrid_Name_HeaderText, width: 10, type: accountCell },
    { field: "FromAccount.Address.CityStatePostal", name: 'City/State/Postal', width: 20, type: addressCell },
    { field: "ForwardRelation", name: AccountAssociationsResource.AccountAssociationsGrid_Relation_HeaderText, width: 8, type: relationshipCell },
    { field: "ForwardNotes", name: AccountAssociationsResource.AccountAssociationsGrid_Notes_HeaderText, width: 20, type: descriptionCell, formatter: Sage.Format.abbreviationFormatter(128) },
    { field: "CreateUser", name: AccountAssociationsResource.AccountAssociationsGrid_CreatedBy_HeaderText, width: 10, type: slxUser },
    { field: "CreateDate", name: AccountAssociationsResource.AccountAssociationsGrid_Date_HeaderText, width: 10, type: dateTime, dateOnly: true }
],

Our new column is the following row:

{ field: "FromAccount.Address.CityStatePostal", name: 'City/State/Postal', width: 20, type: addressCell },

The “field” value is the field the column is bound to, the “name” is the column heading/caption, we’re specifying a wider width to allow for the value to show, and the “type” is the crucial part here. We need to define a custom column type to translate between the “From” account’s address and the “To” account address, depending on which side of the association we’re currently looking it. If we’re looking at the “From” account record, we want to see the “To” account’s address listed since the “To” account is what will be showing in the grid, and vice-versa. We’re telling the grid that the column’s type is “addressCell”, so now we need to define what an “addressCell” is.

Just above in the code, you’ll see some other cell types defined, for things like “descriptionCell”, etc. We’ll be creating one of those. Just above the “var options” line (on line 65), add the following code:

var addressCell = dojo.declare(dojox.grid.cells.Cell, {
    format: function (inRowIndex, inItem) {
        return utility.getValue(inItem, "FromId") == parentId
               ? utility.getValue(inItem, "ToAccount.Address.CityStatePostal") 
               : utility.getValue(inItem, "FromAccount.Address.CityStatePostal");
    }
});

That code get’s the “FromId” from the row’s data (which is passed in as “inItem” and check’s to see if it matches the “parentId” (parentId is declared at the top of the code, which is the ID value of the account record we’re looking at, the “current ID”). If the “FromId” matches the parentId, we’re looking at the “From” account’s record, so we need to return the “To” account’s address. Otherwise we return the “From” account’s address.

The end result will look like this:

Associations Tab Address

After deploying, keep in mind that you might not see changes right away since the js file is likely cached by your browser. You can force to see the changes by clearing your browser cache and refreshing.

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.

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!