Wednesday 2 March 2016

Unable to distribute Campaign Activities, Error retrieving next number (currentbulkoperationnumber) ..

In a CRM system we were having trouble distributing campaign activities, we would always get the following error 'Error retrieving next number (currentbulkoperationnumber) for organization {e14513f2-5cdb-4194-9ca1-52d04cd0b077): return value is empty'.  No matter what entity was in the marketing list the distribute would fail after choosing the owner.  What was equally perplexing new organisatios wouldn't have this issue.

We started getting this error in CRM 2011, my hope was upgrading to CRM 2016 would resolve this error, unfortunately not.

After doing a SQL trace on the SQL server we managed to find 1 SQL query which looked suspect.

exec sp_executesql N'declare @currentval int
update OrganizationBase set @currentval = CurrentBulkOperationNumber, CurrentBulkOperationNumber = CurrentBulkOperationNumber + 1 where OrganizationId = @orgid
select @currentval',N'@orgid uniqueidentifier',@orgid='E14513F2-5CDB-4194-9CA1-52D04CD0B077'

The CurrentBulkOperationNumber field in our OrganizationBase table was currently set to NULL, updating this to 1000 resolved the issue.

 UPDATE OrganizationBase SET CurrentBulkOperationNumber = 1000

This does make me wonder what other data issues are lurking in our database, that we just haven't noticed yet.