back to top

Custom Entity Properties and Displaying the Primary Contact on the Account Detail Form

A question was asked in the SalesLogix Business Partner newsgroups about how you would go about adding the Primary Contact for an account to the AccountDetails form. I thought this was a great idea for a post since there are many ways to go about doing this, some of them better than others. Your first reaction might be to write some code on the form, in a LoadAction, to set a control with the value of the account’s primary contact. However, you’ll find that you have the easiest time, now – and when it comes time to upgrade, if you keep things in the entity model as much as possible. Wouldn’t it be nice if we had a property on the account that returned the primary contact so we could just use normal binding to display it where needed, on any form without writing the code over and over again to retrieve the primary contact? We can do just that if we implement this using a custom property on the Account entity.

In the AA, drill down to the Account entity. Then right-click on the Properties folder under it an select the “New Custom Property” menu item. You’ll get a screen where we can add code for this custom property. Set the following for the custom property:

  1. Property Name = “PrimaryContact“
  2. Read Only
  3. Return Type = “Sage.Entity.Interfaces.IContact“ (you’ll just have to type it in, it won’t be listed in the drop-down)

Now we’ll add the following code to our new PrimaryContact custom property:

public virtual Sage.Entity.Interfaces.IContact PrimaryContact
{
    get
    {
        Sage.Entity.Interfaces.IContact primarycontact = null;
        foreach (IContact contact in this.Contacts)
        {
            if (contact.IsPrimary.HasValue && contact.IsPrimary.Value)
            {
                primarycontact = contact;
                break;
            }
        }
        return primarycontact;
    }
}

 

This code is easy enough, but the cool part is that this will now be a part of the Account entity. We won’t have to write it ever again, and to display the Primary Contact for an Account, we can jus bind it up. Note that we made this property ReadOnly. We could make this a read/write property, we’d just have to implement the code in the “set” property to set the IsPrimary flag on the contact passed in. Also, it is worth pointing out, that booleans in SalesLogix are almost always of type bool? (a nullable bool), not just a standard bool. This means that you need to not only check if the IsPrimary property is true, but also check that it has a value (so you don’t get an error if you come accross a contact with a null value for IsPrimary).

To use this custom property on a form we will need to build the interfaces for our platform. Once that is done, open the AccountDetails form. We will add a new control on the form that is a “Link” control. We will need to set a property on this Link control to tell it that we’ll be linking to a Contact. Set the Link control’s “EntityType” property to “Contact”. Then open the DataBindings. Here we will set two bindings:

  1. EntityId = MainEntity.PrimaryContact.Id (Note, you’ll need to map to the new PrimaryContact property on the account, just select it from the left side and click “Map“. Then type in “.Id“ at the end of it – see screenshot below)
  2. Text = MainEntity.PrimaryContact

Once you’re done there, save the form. Remember, now that you’ve added this custom property to the Account entity, you can use this where ever you want, on any account screen (or easily grab the primary contact via code using account.PrimaryContact)

Time to take a look. Build the web platform, then deploy the site. The result will look like this (you’ll also be able to click it to jump to the primary contact since we used a Link control for this):

Enjoy 🙂

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Ryan Farley
Ryan Farleyhttps://customerfx.com/article/author/ryanfarley/
Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. 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.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Infor CRM SLX 10.0: Delegate Ownership Changes for “Everyone” Records

Learn how the new EveryoneOwnerAssignment secured action in Infor CRM SLX 10.0 allows designated users to change ownership of Everyone-owned records without requiring Administrator access.

Related Articles

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Related Videos