Custom Format Columns in SalesLogix Web (and Linking to External Sites in a DataGrid)

There might be times when you need to do some custom formatting in SalesLogix DataGrids that goes way beyond just simple formatting. A perfect example of this is taking a simple value, such as an indentifier from another external system where you want the value in the DataGrid to be a part of a hyperlink to this other system. In this scenario, you might have a value like “12345”, which identifies a matching record in another system and you want this to become a value like the following in the grid:

<a href="http://theothersystem.com/something?id=12345">12345</a>

This is where the CustomFormatColumn column type comes in. The problem is that this column type can be a little confusing and not well documented.

In this scenario, we’ll just use a sample of adding a hyperlink into the Account Contacts grid to do a Google search on the contact’s full name. Not really useful, I know, but it will serve the purpose of demonstrating how to use a CustomFormatColumn.

Basically, the way that a CustomFormatColumn works is you create your own custom C# function. The value, from each row, in the grid is passed into your function. You do whatever you need to do with the value in your code and then return the result, which is what will appear in the grid.

In the DataGrid on the AccountContacts QuickForm, add a CustomFormatColumn. There are four properties we’ll need to make sure we set.

  1. ColumnHeading = The title or caption for the column.
  2. DataField = This is field/property on the entity that you want passed into your function. For our example, we’ll pass in the contact’s FullName property.
  3. FormatMethodName = This is the name that you’ll be calling your function. For our example, we’ll call our function “GoogleLink”
  4. FormatCode = This is the C# code to do what is needed to the value so it displays the way you want in the grid. See the code for our example below:
protected string GoogleLink(object name)
{
return string.Format("<a href="http://www.google.com/search?q={0}" target=_blank>{0}</a>", name);
}

One thing to point out here, the parameter getting passed in will need to be an object and you’ll be returning a string. Also, you must include the complete function signature with the method name matching (case-sensitive) the name you have in the FunctionMethodName property. The properties for our CustomFormatColumn will look as follows:

The thing that will look weird, is the code in the Format Code property. As I mentioned before, you must include the complete signature of the function. The code window, however, will try to tell you that the code is not valid and it will appear as if you’re adding a function into a function, but you’re not. The code you type into this window will get added to the SmartPart and the grid column will wrap itself in the function call. You can see the weirdness I am referring to in the screenshot:

Notice the red squigglies and the apparent method signature at the top of the window. Ignore those. You’re doing just fine. After deploying, you can see the final result. A link in our grid that will launch a new window and take you to a search results page on Google.

 

A bit more real world, this would be another web app showing some details for that contact, like maybe products purchased or something from an accounting system. You can go far beyond simple formatting with this. If we wanted, we could pass in some identifier from the other system and then grab a value from that system’s database or via a web service call to get some value to show in the grid. However, beware, that while that is possible, keep in mind that this will execute for each row in the grid, delaying the load time for the grid and SmartPart so use discretion when moving beyond simple formatting.

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.

2 Comments

  1. If i need open an ADD EDIT FORM…. how can make this?

    Reply
  2. Is it correct that “custom format” columns have now been migrated into columns that allow a custom format function? Like the “Editable field” column? (We are running a current 8.3 web only environment)

    Reply

Submit a Comment

Your email address will not be published.

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!