Notifications
Announcements
No record found.
Hi,
Does anyone know how to set the primary key in entities. I want to create an ID for each record in account, how can I set that field as the primary key?
Thank you in advance
*This post is locked for comments
Hey Rachelle,
When the Entity is created, it does have a already built Primary Field. You do not externally need to create it. Also when you create a record for a Entity, Guid (Id) will be also automatically set. But if you want to set a lookup filed Then you need Guid, Name and Logical Name of the record.
Below code might be of help!!!
var lookup = new Array(); lookup[0] = new Object(); lookup[0].id = recorid; lookup[0].name = recordname; lookup[0].entityType = entityname; Xrm.Page.getAttribute("attributename").setValue(lookup);
If you are creating a new record in the system, it will automatically set the Guid for you, however, if you are importing data, and you want to set the Guid yourself you can do it either from the SDK (using C#/.NET code), by supplying the Guid of the record, or if you are using SSIS with KingswaySoft for example, you can specify the Guid of the record that you will be creating there.
Hope this helps.
Hi RachelleM,
You can create a key field this will be alternate key but wont be primary key but acts as primary key. As we can have only one Primary key.
Please follow below links to generate GUID dynamically.https://weblogs.asp.net/haithamkhedre/generate-guid-from-any-string-using-chttp://www.c-sharpcorner.com/UploadFile/prasoonk/guids-in-C-Sharp-and-net/ThanksHemant
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2