Posts in Category: uncategorized

Bulk Delete with Dynamics365

No matter what project you are on, you are at one point or another going to need to delete data.

Your environment will become polluted and you going through each entity or manually queuing up your own delete jobs will not be worth your time.

To bulk delete your entire environment you can make use of the Bulk Delete API with the following lines of code.

QueryExpression bulkquery = new QueryExpression();
bulkquery.EntityName = entity.LogicalName;
bulkquery.Distinct = false;

BulkDeleteRequest request = new BulkDeleteRequest
{
JobName = String.Format("System Purge Requested for Entity [{0}] - All Records", bulkquery.EntityName),
QuerySet = new[] { bulkquery },
StartDateTime = DateTime.Now.ToUniversalTime(),
ToRecipients = new[] { currentUserId },
CCRecipients = new Guid[] { },
SendEmailNotification = false,
RecurrencePattern = String.Empty
};

ExecuteMultipleResponse response = new ExecuteMultipleResponse();
response = (ExecuteMultipleResponse)_svc.CrmService.Execute(multipleRequest);

Of critical importance is the

Read More


Dynamics SDK Fault Errors

Recently I was running some code against the Dynamics SDK that was taking a significant amount of time to run (transferring of data).  In my naivety, I had thought that by constantly doing “something” on that live connection my token would be refreshed.

Not the case.

It seems tokens from the Dynamics SDK are set at the time of connection and kept for the duration of the connection and not updated until you do so again.

To avoid having my connection cut during this migration (which was bad), I added some logic to check when the connection had last logged in, do a quick comparison of X minutes (in my case I chose 90 minutes but it could be more) and triggered a reconnect/refresh of my token.

The code is nothing spectacular, but understanding

Read More


Comments are King

///

That is all it takes to explain what you are doing, why you are doing it, how you are doing it and where you will do it.

It’s not rocket science, it’s not complicated, it doesn’t add hours to your coding effort and in some cases it has the potential to be an added dose of humour to your fellow colleagues as you work through a particularly stressful problem.

Comments were put to me in the best way possible years ago…

Imagine the person behind you is a Crazed Serial Killer and your lack of comments will be the tipping point for them.

Comment your code not only for your team, but for yourself, so you remember why you wrote it, what stress you were under and why it shouldn’t be refactored.

Dynamics Plugins and

Read More


What it is

Over the past few years, I’ve found myself drifting further from code and not developing as much as I’d really like to be.

Over the past few months I’ve been experimenting with LinkedIn as a blogging platform for technical articles and it really hasn’t felt it like it quite cuts it.  Coupled with this, I used to blog about anything technical that I was doing – Powershell, Lync, C#, SQL, etc – but then started to break it out by technology for better readability.  But that always left me with more to say and nowhere to say it.

So, I’m going back to a single technical blog, about everything and anything as I jump into everything going on around me.  In the coming months, I’m probably going to be focussing more on the Dynamics

Read More