After a short unplanned break we are back! For the past three weeks we’ve been travelling and taking part in Ignite, crafting and teaching BAD Masterclass, and preparing for CRMUG Summit which did leave us with a choice to either breathe or publish CRM Tip of the Day. Good news is that we survived and stashed some juicy tips waiting to be shared. Now, to the tip.
Frequently during the data import we need to preserve historical ownership of the data. Dynamics 365 Online does not allow creating user records in UI. Adding users in Office 365 portal, assigning Dynamics license, and then deleting the users is the only interactive way to create disabled user accounts.
It is possible to create disabled users by importing CSV file, but on odd occasion programmatic creation is required. Challenge is/was to come up with an absolute minimal set of fields required to create a “dead soul”. Here we go:
var user = new Entity("systemuser"); user["firstname"] = "test"; user["lastname"] = "testroni"; user["internalemailaddress"] = "test@samples.com"; user["businessunitid"] = new EntityReference("businessunit", new Guid("deadbeef-0aad-e711-a96d-000d3bb10143")); user["windowsliveid"] = "test@sample.com"; var userid = service.Create(user);
Similar code can be used in PowerShell, JavaScript or any other language of your choice.