I need to one-way-synchronize external Data with CRM on a regular basis (i.e. nightly).
This includes creating new Records as well as updating existing ones.
That means, I have to keep track of IDs of CRM-Entities created by my synchronization process.
emphasized textI already managed to create and update records in CRM from lines of database-tables so this is not a problem.
id
: The tables primary key set when inserting a new rownew_myentityid
: Primary Attribute of the mapped entity, set after the record was created by the synchronization processnew_name
etc.: the values of the records attributesInstead of having a PrimaryKey (id
) in the database and keeping track of the CRM ID (new_myentityid
) in a seperate column, I could as well get rid of the id
-columns and make the CRM-ID-Column (new_myentityid
) primary key of the table and set it when inserting new records (newid()
), so basically substitute id
with new_myentityid
from a database perspective. I could then bulk-upsert via ExecuteMultipleRequest
in combination with UpsertRequest
.
This way, I would save a column in each mapped table as well as logic to store the CRM IDs after creating them.
Would this be acceptable or is there anything that should make me avoid this?
Disclaimer: I'm not aware of a best practice for this so this is just my personal opinion on the matter having developed for Dynamics several times.
I think that using the CRM Entity GUID for your primary key is a good idea. It's less complicated and is handled well in SQL. I assume the column in your database is uniqueidentifier
.
My only comment is to not generate the GUIDs yourself. Let CRM generate them for you as it does a better job at keeping everything sequential and indexed.