Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, November 22, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 External Development Forums - General External Development
Forum to discuss general external development topic (related or not to SalesLogix development). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to General External Development | New ThreadView:  Search:  
 Author  Thread: [sublogix] Create new id for custom entities?
Andrei Kruglov
Posts: 11
 
[sublogix] Create new id for custom entities?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Jul 12 8:37 AM
fiogf49gjkf0d
I've create my custom Entity named 'KalugaAstral' but when i try to add new elemet i've got an error:

var kalugaAbonent = _repository.Create();
kalugaAbonent.RegNum = (short) abonent.REG_NUM;
kalugaAbonent.ServerDir = (int) abonent.SERVER_DIR;
kalugaAbonent.GuId = abonent.GUID;
lock (_repository)
{
kalugaAbonent.Save();
}

So i need to generate kalugaAbonentId before saving item. Is any method to create ID?
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: [sublogix] Create new id for custom entities?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Jul 12 12:49 AM
fiogf49gjkf0d

Sublogix will create the primary ID value automatically. However, you need to specify the entity type you are creating.


Like this:


var kalugaAbonent = _repository.Create<KalugaAbonent>(); // <-- or whatever the entity type is
kalugaAbonent.RegNum = (short) abonent.REG_NUM;
kalugaAbonent.ServerDir = (int) abonent.SERVER_DIR;
kalugaAbonent.GuId = abonent.GUID;
lock (_repository)
{
    kalugaAbonent.Save();
}

As long as this entity is based on a normal SLX table, it will create the primary ID value for it when you save (but you do need to specify the entity type when you create, otherwise it will generate an error.


Not that you need this for standard saves like the above, but you can also create ID values with Sublogix using the following:



var newAccountId = Sublogix.Helpers.SalesLogixHelper.NewID<Account>();


BTW, what is the specific error text you were getting?

[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/22/2024 4:42:50 AM