Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Tuned Listener
Posts: 26
Registered: ‎06-28-2010

Automatically Generating IDs

Hello everyone,

I am trying to update a credit card table with new credit cards. I now need to be able to generate a credit card id in order to have fill the unique key requirement of the table. Does anyone have any leads as to where I should start? Here is the code I currently have.


            IContact current = (IContact)form.CurrentEntity; //Gets the current entity
            //Create a new placeholder for the new credit car information

            IContactCreditCards newCC = Sage.Platform.EntityFactory.Create<IContactCreditCards>();

            newCC.Address1 = form.tbox_Address1.Text;//Adds the address(more fields to come)
            newCC.C_Contact_creditcardsId = form.ccSID; //This is where I need to generate an id to put into the table
            newCC.Contactid = current.ContactId; //The current contacts ContactID
            newCC.Save(); //submit to the db


Thank you in advance!


Posts: 535
Registered: ‎03-30-2009

Re: Automatically Generating IDs

The PKID value for an Entity will be created automatically by the ORM model when the new Entity instance is persisted to the DB via .Save()


In your case, I believe the IContactCreditCards entity is a child of Contact?

P.S. - suggest you use singlar on Entity names and plural on Relationships.


If it works for your scenario, you could consider adding the newCC entity to the Contact.ContactCreditCards collection. Assuming the relationship between Conact and ContactCreditCard has been defined with Cardinality including "Save", then when the Contact entity is ultimately Saved, all new or modified child entities (the ContactCreditCard entities) will also have their respective .Save() methods called.

Todd Hardin
SalesLogix Professional Services Group