Displaying the Primary Contact on the Account Detail Form Revisited and Custom Properties in 7.2.2

I posted before about adding the primary contact to the Account Details form in the SalesLogix 7.2 Web Client. This solution made use of “Custom Properties” which was a feature available in 7.2.1. However, since that time, a change was introduced to how custom properties are built in 7.2.2 and later. Custom Properties are no longer available (although custom properties built prior to 7.2.2 will still work when you upgrade without change).

Let’s take a look at how this changes things using the same example as before (placing the account’s primary contact on the account details form). As I mentioned, Custom Properties are gone. We now have “Code Snippet Properties”. The major difference between a 7.2.1 Custom Property and a 7.2.2 Code Snippet Property is that a Code Snippet Property is the following:

  1. Code Snippet Properties are read-only. That is, they have a getter only, no setter.
  2. The code in a Code Snippet property is no longer exactly a part of the entity. This measn that before, you could reference properties/methods of the entity using “this”, while now, you are passed in a reference of the entity as a parameter.
  3. The implementation of the actual code for the Code Snippet Property is a void method. That’s right. It doesn’t actually “return” anything. Instead, there is an out parameter (of type “object”) that you set as the return value.
  4. While the implementation code is a void method with an out param for the result, you still use it as a property. There is a property that will wrap the method and allow you to use it like a property. This allows you to still easily bind it.

All of this change was mainly to separate the code for the property from the entity itself, allowing the implementation code to be in C# or VB.NET, whereas before you could only use C# (which was fine with me, hehe).

Anyway, to create the “PrimaryContact” property, there are only small changes we’ll need to make. First of all, right-click on the Account entity Properties folder and select “New Code Snippet Property”. You’ll get the following:

You’ll want to set the following:

  1. Property Name: PrimaryContact
  2. Return Type: Sage.Entity.Interfaces.IContact (just like before, you’ll have to just type this in. It won’t appear in the drop-down list)
  3. Click Add. This will create the step’s snippet stub
  4. Click Edit Code Snippet. This will bring up the code window

Now enter in the following code:

namespace Sage.BusinessRules.CodeSnippets
{
    public static partial class AccountBusinessRules
    {
        public static void GetPrimaryContactStep1(IAccount account, out Sage.Entity.Interfaces.IContact result)
        {
            Sage.Entity.Interfaces.IContact primarycontact = null;
            foreach (IContact contact in account.Contacts)
            {
                if (contact.IsPrimary.HasValue && contact.IsPrimary.Value)
                {
                    primarycontact = contact;
                    break;
                }
            }
            result = primarycontact;
        }
    }
}

You’ll notice that the current account reference is passed in as a parameter to the method and that you’ll set the out param as the return value. That is it. Build the interfaces and then you can add it to the Account Details form just like I had posted earlier (see previous post).

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, 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!