The SalesLogix entity model implemented in the web client takes a lot of burden of developers. In the LAN based SalesLogix application, developers worked directly at the database level and were responsible for generating keys and other required fields when inserting data into a table. The entity model handles key generation automatically so that the simple act of adding a new entity record will automatically populate the primary key and other fields like CREATEUSER and CREATEDATE.
There may be cases where you do want to get a ID for a table in the SalesLogix Web environment like you used to be able to do in the SalesLogix LAN client with a call to Application.BasicFunctions.GetIDFor(“HISTORY”). Lets look at how.
Sage.SalesLogix.SalesLogixEntityKeyGenerator keyGenerator =
new Sage.SalesLogix.SalesLogixEntityKeyGenerator();
With the entity key generator instantiated you can now access it to generate as many IDs as you want. The GenerateIDs method will return a list of IDs for the entity passed into the first parameter of the method. The second parameter specifies how many keys to generate.
List<string> keys = new List<string>(keyGenerator.GenerateIds(typeof(Sage.Entity.Interfaces.IHistory), 1))
With the list you can then loop through and use them:=. A simple way to access the first ID in the List
string newID = null;
foreach (string key in keys)
{
newID = key;
break;
}
All together the code is:
Sage.SalesLogix.SalesLogixEntityKeyGenerator keyGenerator =
new Sage.SalesLogix.SalesLogixEntityKeyGenerator();
List<string> keys = new List<string>(keyGenerator.GenerateIds(typeof(Sage.Entity.Interfaces.IHistory), 1))
string newID = null;
foreach (string key in keys)
{
newID = key;
break;
}
There you go. A simple way of generating Keys.




good post, thanks for post, +1))))