Login / Register  search  syndication  about

          Ryan Farley's Blog

Ryan Farley on .NET Development with a focus on CRM Development for SalesLogix

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 :-)

What's This?
  
Bookmark and Share

About Ryan Farley

   Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix since 2001 and believes in sharing with the community. He loves C#, Javascript, Python, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

View the SalesLogix Mobile Seveloper Series
View the SalesLogix SData Developer Series
View the Git for the SalesLogix Developer series



Related Content
   Easily Showing and Hiding Tabs at Runtime in Infor CRM (Saleslogix)
Showing and hiding tabs in the Infor CRM (Saleslogix) client should be an easy thing. It should be someth
Posted on Dec 16, 2014 by Ryan Farley to Ryan Farley's Blog
 
   Avoiding the Dirty Data Message When Programatically Redirecting to a Record in Infor CRM (Saleslogix)
In my last post I wrote about using the OnClientClick property of a control (or button) to run JavaScript
Posted on Dec 02, 2014 by Ryan Farley to Ryan Farley's Blog
 
   Confirming Actions With an "Are you sure?" Prompt in Infor CRM (Saleslogix)
I'm not a huge fan of bugging end users. I figure, if an end user clicked something, he or she meant
Posted on Nov 18, 2014 by Ryan Farley to Ryan Farley's Blog
 
   Programmatically Using Security Roles and Secured Actions in Infor CRM (Saleslogix)
In most places in the Infor CRM (Saleslogix) web client, it's pretty easy to use security roles. You
Posted on Nov 07, 2014 by Ryan Farley to Ryan Farley's Blog
 
   Using a Test Plan
So you have approved the Statement of Work (SOW) for some modifications and are awaiting the delivery of
Posted on Mar 13, 2014 by George Jensen to George Jensen's Blog
 
Comments

 

Mark Dykun said:

Ryan,

Like the method. I would add a second method to the class Values that can return an array of id's as well.

Mark

May 7, 2008 3:01 PM
 

Ryan Farley said:

I've not used this in an app yet that had a need for multiple ID values to be created at once, but that would be a great addition.

Signature would look like:

public List<string> Values(int Count)

Which would make for some nice syntax:

List<string> idlist = new TableID("ticket").Values(10);

Very nice.

-Ryan

May 7, 2008 3:13 PM
 

Jim Forte said:

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?

May 8, 2009 2:35 PM

Leave a Comment

(required)  
(optional)
(required)  
Add
All contents Copyright © 2014 Customer FX Corporation
Customer FX Corporation
2324 University Avenue West, Suite 115
Saint Paul, Minnesota 55114
Tel: 800.728.5783

  Follow @CustomerFX on twitter
Follow the best news, tips, and articles
  Subscribe to Customer FX on youtube
Watch SalesLogix tutorial videos from Customer FX
Login / Register