
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 🙂
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?