Elegant SalesLogix Table ID Class in C#

I’ve been using the following C# class for creating SalesLogix table ID values lately and I just love the elegant syntax it provides. It’s really been growing on me.

Here is the class:

using System;
using System.Data.OleDb;

namespace SalesLogix.Utility
{
    public class TableID
    {
        private string _table = string.Empty;

        public TableID(string TableName)
        {
            switch (TableName.ToUpper())
            {
                case "ATTACHMENT": _table = "FILEATTACH"; break;
                case "USERNOTIFICATION": _table = "USERNOTIFY"; break;
                case "AGENTS": _table = "HOSTTASK"; break;
                case "RESOURCELIST": _table = "RESOURCE"; break;
                case "USEROPTION": _table = "USERVIEW"; break;
                case "JOINDATA": _table = "JOIN"; break;
                case "PROCEDURES": _table = "PROCEDURE"; break;
                case "SEC_FUNCTIONOWNER": _table = "FUNCTIONHANDLER"; break;
                default: _table = TableName; break;
            }
        }

        public override string ToString()
        {
            return this.Value;
        }

        public string Value
        {
            get
            {
                using (OleDbConnection conn = new OleDbConnection(Globals.ConnectionString))
                {
                    conn.Open();
                    using (OleDbCommand cmd = new OleDbCommand(string.Format("slx_dbids('{0}', 1)", _table), conn))
                    {
                        return cmd.ExecuteScalar().ToString();
                    }
                }
            }
        }
    }
}

Nothing out of the ordinary there, but the really nice part comes from it’s usage:

string ticketid = new TableID("ticket").Value;

I like it 🙂

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.

1 Comment

  1. Question. I am trying to build a contactID outside of windows in perl, using freeTDS. Any thoughts on how I can build it without the functions built into sales logix?

    Reply

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!