CRM 2013 – Workflow error AccessCheckEx

I was investigating a bug on CRM 2013 , I got the exception below

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: SecLib::AccessCheckEx failed. Returned hr = -2147187962, ObjectID: f115e97d-8e19-e511-80ca-000c292122be, OwnerId: 89ed0bdd-7ecd-e411-80c7-000c292122be,  OwnerIdType: 9 and CallingUser: 2ed69167-0bcf-e411-80c7-000c292122be. ObjectTypeCode: 4200, objectBusinessUnitId: 5f964320-05f4-e411-80c9-000c292122be, AccessRights: WriteAccess Detail:
<OrganizationServiceFault xmlns:i=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns=”http://schemas.microsoft.com/xrm/2011/Contracts”&gt;
  <ErrorCode>-2147220891</ErrorCode>
  <ErrorDetails xmlns:d2p1=”http://schemas.datacontract.org/2004/07/System.Collections.Generic”&gt;
    <KeyValuePairOfstringanyType>
      <d2p1:key>OperationStatus</d2p1:key>
      <d2p1:value xmlns:d4p1=”http://www.w3.org/2001/XMLSchema&#8221; i:type=”d4p1:string”>0</d2p1:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <d2p1:key>SubErrorCode</d2p1:key>
      <d2p1:value xmlns:d4p1=”http://www.w3.org/2001/XMLSchema&#8221; i:type=”d4p1:string”>-2146233088</d2p1:value>
    </KeyValuePairOfstringanyType>
  </ErrorDetails>
  <Message>SecLib::AccessCheckEx failed. Returned hr = -2147187962, ObjectID: f115e97d-8e19-e511-80ca-000c292122be, OwnerId: 89ed0bdd-7ecd-e411-80c7-000c292122be,  OwnerIdType: 9 and CallingUser: 2ed69167-0bcf-e411-80c7-000c292122be. ObjectTypeCode: 4200, objectBusinessUnitId: 5f964320-05f4-e411-80c9-000c292122be, AccessRights: WriteAccess </Message>
  <Timestamp>2015-06-23T10:02:24.458209Z</Timestamp>
  <InnerFault i:nil=”true” />
  <TraceText>

[Microsoft.Crm.ObjectModel: Microsoft.Crm.ObjectModel.SyncWorkflowExecutionPlugin]
[0dac4467-fb18-e511-80ca-000c292122be: ]
Starting sync workflow ‘Task-Workflow’, Id: 04ac4467-fb18-e511-80ca-000c292122be
Entering ConditionStep1_step: If  Process contains data and is active
Entering SetStateStep4_step: Change record status to completed
Sync workflow ‘Task-Complete’ terminated with error ‘SecLib::AccessCheckEx failed. Returned hr = -2147187962, ObjectID: f115e97d-8e19-e511-80ca-000c292122be, OwnerId: 89ed0bdd-7ecd-e411-80c7-000c292122be,  OwnerIdType: 9 and CallingUser: 2ed69167-0bcf-e411-80c7-000c292122be. ObjectTypeCode: 4200, objectBusinessUnitId: 5f964320-05f4-e411-80c9-000c292122be, AccessRights: WriteAccess ‘
</TraceText>
</OrganizationServiceFault>

Initial thoughts on the Error

I got this error and there were a few things I found interesting

This error was surprisingly informative

The error was thrown by a non code workflow but the cause of the error was thrown by a GUI workflow which was being triggered when a workflow tried to assign an activity.

I was impressed by the level of logging which was generated by a GUI/non code workflow.

I had never thought about it but this line

Microsoft.Crm.ObjectModel: Microsoft.Crm.ObjectModel.SyncWorkflowExecutionPlugin

indicates CRM runs the GUI workflows using code, which must translate the actions into code. This is obvious but I hadn’t thought about it, until seeing the error.

You can use the callerid to find what user is doing the update and check what security roles the user has.

EntityTypeCode

In the error message you can see it mentions ObjectTypeCode

CRM 2011/2013 – Javascript to get the object type code of an entity

Each entity has an individual typecode, this CRM SDK page shows you the values of the default entities

Entity Type Code 4200 is ActivityPointer, which is interesting because the problem was being caused by an update to a task record.

Clues

AccessCheckEx failed – AccessCheckEx is something to do with security and access

In the error message you can see

AccessRights: WriteAccess

This is clearly telling us the user doesn’t have Write access, e.g. the user isn’t allow to update a certain

What was the cause

This bug was partly caused by the complexity of the CRM solution and the different customizations.

Solution complexity refer to not only the customizations which exist in the solution but the number of different customizations.  When a CRM solution has lots of different customizations e.g. workflows, plugins, business rules being triggered at the same time it makes it difficult to understand what is changing a value.

Below is what was happening

  1. A task was updated then saved
  2. This triggered a pre plugin on the task entity
  3. The plugin assigns the case record
  4. A plugin was triggered on assign of the case, which assigned all the open tasks to the new case owner
  5. The plugin(s) finished
  6. A workflow was triggered, which tried set the task to complete.

The error was thrown because the workflow was trying to update the task but the user only had privileges to update tasks they owned.

The reason this bug suddenly appeared was because the assign plugin was added and it wasn’t picked up in DEV testing because developers tested the code using users with System Admin privileges, which I have talked about before

The System Administrator role is a benefit and a curse to CRM developers

It’s tricky to test the effect of adding plugins

Having lots of different types of customizations adds to the complexity of your CRM solution, complex solutions are difficult to debug, understand and extend.

The Solution

Usually with bugs where the user doesn’t have the right security privilege the easy answer is to give the user role those security privileges.

For this bug it wasn’t the correct solution because the users only had access to tasks they owned and we didn’t want to suddenly give them permissions to update tasks they didn’t own.

The plugin code was running in a PRE plugin, so I couldn’t move the task completing code into this plugin.

The bug was becoming more tricky because I did want to keep the case assigning code in their but I didn’t want the assigning case plugin to run and assign the task to the new case owner because the task was about to completed.

My solution was to stop the assign plugin being triggered if was called by another plugin

Read how to do that in the blog below

CRM Plugins – Stopping infinite loops and understanding PluginExecutionContext.Depth

I then created a post task plugin to complete the task.  I didn’t need to do this but it seemed it would be easy to understand if all the changes were made by plugins.

There was an unsuccessful fix when I used impersonation to close the task as System Admin but the users didn’t like the tasks being closed by System Admin, they wanted the user who updated the task to complete the task.

You can read about Impersonation in plugins in the blog post below

CRM 2015 – Understanding impersonation in plugins and knowing when to use it

CRM 2013 – How to stop these annoying things in Microsoft Dynamics CRM

There are a few common and very annoying problems that annoy me with CRM, so I have decided to group them together in this blog so I can easily and quickly find how to stop them.

Disable Send Report to Microsoft pop up

I personally have always wondered what Microsoft does with all those error reports it asks people to send!

You might be tired of clicking on these message and you probably don’t want your end users to see this popup.

Good news – Luckily Microsoft have added a setting we can turn off

Bad news – it’s hidden in a place where no one would dream of looking

If you want to stop this message, you need to go to

Settings –> Administration –> Privacy Preferences –> tick box and select Never send

privacy settings

Users get created with the wrong format

This is a common and annoying problem for UK CRM Developers.  You create a new organisation which as the default English (United States).  This is clearly no good for UK users because the Americans have got their months and days mixed, currency dollars etc.

All the users you add will be given the same Format settings as the default.

Once a user is created the only way to change their format settings is to go into their personal options and change the format settings.

The way to avoid setting users with English (United States) is to change the Current Format in the System Settings to English (United Kingdom) and then create your users.

Stop the Annoying Welcome Woman

To do this you have to add a registry key.  I found the instructions on the awesome power object blog How to Disable the CRM 2013 Welcome Screen

On the CRM server in open Regedit

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM

Add a new DWORD (32-bit) and call it DisableNavTour

Disable Hello woman

Annoying outlook download message

Microsoft is always trying to persuade people to download Outlook, if you have got annoyed at this message you can turn it off by flicking a switch in System Settings

Outlook message turn off

Get rid of annoying pending email warning message

The annoying pending email message has plagued me a number of times.  There are two ways to get rid of it.

1. Delete the pending emails, instructions here

2. Modify CRM Server registry setting DisablePendingEmailReminder to 1.  Instructions in this blog

CRM 2013 Navigation is slow and tricky

Quite how Microsoft made CRM 2013 slower and more difficult to navigate than CRM 2011 is a mystery but it was probably a decision they made whilst banishing the Start menu from Windows 8.

I have talked about it in this blog – Good CRM design should not make users think

You have a couple of good options

CRM 2013 One Click solution

Use these Bookmarks to help speed your navigation

CRM Navigation Hacking with Bookmarks

Trusted Sites

This isn’t a problem but something you need to remember when setting up CRM for customers you need to make sure you add CRM to IE’s trusted sites

How to Add CRM to Trusted Sites

CRM is acting weird, option sets don’t work properly

If you are using IE, trying playing with compatibility mode settings on your browser

Configuring Settings for IE 10 and CRM 2011

The article only mentions CRM 2011 and I can’t remember if I had these problems in CRM 2013 but I thought I would put it here.

Any more?

If you have any more annoying things in CRM please add them in the comments

CRM 2011/2013 – Ribbon problems

The investigation and problem I experienced where in CRM 2011 but I think it would be the same in CRM 2013, I had a problem with the ribbon javascript but I didn’t have a clue where it was because I had never seen a syntax error in the Javascript ribbon.

I put a debugger statement in the ribbon, so it would drop into the debugger.  The reason you  put the debugger statement into the Javascript code is because when the ribbon is loaded it is loaded in dynamic Javascript script block, this means when you press F5 it creates a brand new script file and you won’t have time to put a breakpoint in it if you bring up the debugger by pressing F12.

 

So I put my debugger line in and then the code hit my various display/enable javascript methods and I could step through them but the syntax error kept appearing.

I still wasn’t sure where/what the problem was.

I pressed F12 to bring up the debugger and this was bring up a syntax error

syntax error

I turned on fiddler and found on one of the calls I was getting a nasty red triangle on one of the calls.

The thing which kept bugging me was it was a syntax error

I could see the code and it looked fine (although syntax errors are not obvious to the naked eye). The file compiled in Visual studio and pressing F12 to get the debugger didn’t throw an error, so this would suggest the javascript syntax was not the problem

 

frustrating

I fired up the Visual Ribbon Editor for CRM 2011/2013

In the Visual Ribbon Editor here you have display rules, enable rules and action.

There was no disable rule

there was an enable rule and an action rule which both called a javascript function, you can see below

ribbon enable
ribbon action

Slowly something clicked, the error was trying to call the action, why was it calling the action whilst loading the form. Logically the ribbon has to make sure the Javascript method exists so when the user presses the button something will happen but why was it triggering a syntax error whislt loading the ribbon?

Syntax error, ribbon load…..hmmmmm

Look at the two rules, although I’m not showing you the actual file, look at the position of the library and the function boxes!

Finally after hours and dragging more eyes to the problem, my colleague found the problem by exporting the Ribbon xml, hazaaar the problem was obvious

The library and function values from the enable rule had been copied into the action rule, only this didn’t work because the function and library boxes are in different places.

He found the library – which should be the javascript library was pointing to a function.

Ribbon object not found

A new day a new ribbon problem.  Today on one of the forms the ribbon wasn’t loading and I was getting an error

 

SCRIPT5007: Unable to get value of the property Ribbon ‘value’ of undefined or null reference

 

The first thing I checked was to see if the function and library values were correct, they were.

In the Javascript files we use we build up the names spaces so the function calls are like this

Hosk.Functions.Account.Ribbon.NewAccount()

To find the problem I had to put debugger statements in the enable/action javascript rules and walk through them.

 

Eventually I found one where Javascript file hadn’t been loaded, so when it it was trying to call a function the javascript file was loaded, the function didn’t exist and we got a null reference.

 

CRM MCC Question and Answer – Guido Preite

I knew it would happen but I have finally run out of CRM MVP’s willing to answer my questions.  Luckily I have lined up a future CRM MVP (in my opinion) Guide Preite who has earned at least two MCC awards.  We get some answers from the boot shaped Italy, where incidentally I went on my honeymoon but not with Guido 🙂

If you don’t know what an MCC award is, I shall let Microsoft explain

 You can also see Guido is 10th in the All time verified answer Leaderboard.  This is a list which features all the Dynamic products (NAV, AX, CRM, GP)
here is his Rockstar 365 highlights
guido

 

1.    Name, current job title and social media links please

Guido Preite

Dynamics CRM Developer

Twitter: https://twitter.com/crmanswers

Blog: http://www.crmanswers.net

LinkedIn: http://www.linkedin.com/in/guidopreite

 

2.    What does an average day at work look like

Writing code, customer support, developing demo and internal tools.

 

3.    What different roles/Job titles have you had whilst using CRM

Developer/Trainer/Consultant

 

4.    What job did you did before you starting using CRM

I used to be a PHP/MySQL developer, but I always liked and used Microsoft languages (I started with QuickBasic 4.5)

 

5.    What was the first version of Microsoft Dynamics CRM you worked with and how long have you been using Microsoft Dynamics CRM

CRM 4.0 – I use Dynamics CRM since 2010

 

6.    How do you stay up to date with the CRM

It’s not easy because Dynamics CRM is a huge platform, I check often Twitter and I mark the interesting tweets as favorite so I can read them later.

 

7.    How do you find time to contribute to the CRM community whilst doing your job

I like to read the questions, I’m curious about the problems encountered in real CRM implementations, and if I can help, why not?

 

8.    What advice would you give to someone who wants to have a successful career in Microsoft Dynamics CRM?

The obvious one: to use the product every day

 

9.    What where your first impressions of CRM 2013 and what do you think now.

“Change is always positive” is one of my mantras and I apply it to CRM as well. I like the new UI, but under the hood several things still need to be improved.

 

10.  What one feature would you add to CRM 2013

OOB read audit (who read what and when)

 

11.  Most annoying feature of CRM 2013

Labels fade if the text is too long, it’s very annoying for some customers

 

12.  You favourite 2 CRM blogs (I have filled the first one in for you)

1.  Hosks Dynamic CRM blog

2.  http://niiranen.eu/crm/ Surviving CRM by MVP Jukka Niiranen

 

13.  What year will Microsoft Dynamics CRM have more customers than Sales force

14.  Are you doing more CRM projects with CRM online?  Do you think it will all be online in the future

CRM Online projects are the majority. I think On Premise will still be relevant for several years.

 

15.  What is the best tool/solution you have used recently

Role Updater (it’s inside XrmToolbox)

 

16.  What CRM certifications do you have, do you try and keep up to date with CRM certifications

CRM 2011: Customization & Configuration, Extending

CRM 2013: Customization & Configuration

 

I have a love-hate relationship with CRM certifications, currently I’m preparing CRM 2011 Applications.

 

17.  How important is it to have good business analytical skills working with Microsoft Dynamics CRM.

Fundamental, a lack of analytical skills can easily screw up a project

 

18.  How useful is it to have programming knowledge to become a good Microsoft Dynamics CRM Professional?

I’m a developer so you can guess my angle, but I think a basic programming knowledge is a must-have for a Dynamics CRM Professional.

 

 

19.  What knowledge/experience do you have with software/systems which integrate with Microsoft Dynamics CRM e.g. (sharepoint, SQL Server, Scribe, Etc)

SQL Server, CWR Mobility, a bit of Sharepoint and NAV.

 

 

20.  How often do you travel as a Microsoft Dynamics CRM Professional?

A few days a year, most to attend conferences or teach courses.

 

21.  Can you see yourself not using CRM in your career in the future

No, CRM is for end users, and we are all end users.

 

22.  What is favourite part of being a CRM MCC

The MCC star badge from Dynamics Community, who doesn’t like badges? 🙂

 

23.  What are your hobbies outside of CRM

I watch tons of TV Series (it’s a good way to improve my English) and I am a big fan of F.C. Internazionale

 

24.   What was the last book you read and what was the last film you watched

Book: “Unions” written by Robert Musil

Movie: “The Hunt” directed by Thomas Vinterberg

 

25.  Has CRM ever got you in trouble with your partner/family.

Sometimes 🙂 my wife is ready to go out and I reply to her “wait a sec, I need to reply to this question”

 

26.  Have you friends ever told you to stop talking/tweeting/blogging about CRM?
Never

 

27.  What does your partner/family member(s) think of CRM

They see I’m passionate about CRM, it’s enough for them

 

28.  Tell me something interesting/unusual about yourself

The movie Chungking Express changed my life, I watched it more than 12 times

 

29.  Who is the first CRM MVP you remember reading/seeing

Jim Wang (http://jianwang.blogspot.com)

 

30.  Tips for someone who wants to become a CRM MCC

Often a question has been asked before: try to avoid link-only answers adding a brief introduction/explanation, it’s important to know also the cause, not only the solution.

 

Quickfire questions (choose one option and no explanation)

Steve Jobs or Bill Gates

Bill Gates

 

Javascript or .NET

.NET

 

Internet Explorer/Chrome/Firefox/Safari

Chrome

 

Wine/Beer/Soft Drink

Soft Drink

 

Certifications or Use CRM

Use CRM

 

twerking or tweeting

tweeting

 

books or ebooks

ebooks

 

save or autosave

save

 

OnLine or On Premise

On Premise

 

Windows 7/Windows 8/Linux/Mac/Other

Mac

 

work from home or work from office

work from home

 

Miley Cyrus or Billy Ray Cyrus

No thanks, I am European

 

Vinyl/CD’s/MP3’s/Subscribe

Amazon AutoRip

 

Zero Inbox/Overflowing Inbox

Zero Inbox

 

Early Bird/Night Owl

Night Owl

 

Do Today/Do Tomorrow

Do Tomorrow

 

CRM Developer/CRM Consultant

CRM Developer

 

Hot Weather/Cold Weather

How Weather

 

Half Full/Half Empty

Half Empty

 

Hosk’s Top CRM 2013 articles of the week 11th July 2014

It’s Friday, cheers everyone and well done Germany.  Only 2 more games to go in the world cup.

 

Article of the Week

Rockton Software ran a competition with a $5000 prize for the best enhancement\improvement to the CRM 2013 UI.   This blog posts show the top five and the winner.  What I found most interesting were the solutions in terms of ideas and technical solution.

The CRM 2013 Navigation Design Contest Winner is . . .

 

Best Of the Rest

 

CRM MVP Andre Margono write a good post on using OData information source in Excel.

Enable Dynamics CRM oData Query Filter for PowerQuery Performance

 

Nice blog post on how to develop a CRM Portal to use with CRM 2013

How to Develop a CRM Portal with Microsoft Dynamics CRM

 

showing process values on forms

Display Business Process Values on Forms in Microsoft Dynamics CRM 2013

 

trick miscellaneous privileges which have multiple access level (e.g. user/business unit/org).  Always good to remind yourself about sneaky privs

Tip #175: Miscellaneous privileges with multiple access levels

 

The new craze of creating Currah’s (in my mind I’m saying Hurrah) with a bunch of useful links on free icons to use in CRM 2013/2011

Free Icons for Dynamics CRM 2011 and 2013

 

Great blog post on how to use Sub Reports and I need all the help I can get with SSRS reports the tricky minxes

CRM 2013: SSRS Report and Sub-Reports

 

If you answer questions on the CRM Forums there will be times when the only answer is to suggest the person raises an enhancment (bugs not allowed !!!)  on Microsoft connect.  So this is a great blog on how to do it.

How to use Microsoft Connect site

 

Entity Images are new in CRM 2013 so you may not know how to show them on the form but you will if you read this article

Tips: How to Display Entity Image on CRM Form

 

CRM 2013 CSS style reference guid

Microsoft Dynamics CRM 2013 CSS Style Reference using Browser Developer Tools

 

A useful workflow to create an alert for the owner of the account when a note is added.

Create a Workflow in CRM to Alert a Record’s Owner When an Activity/Note Is Added

 

VIDEOS

 

Microsoft Social Listening Spring ’14 Analytics Deep Dive

 

Hosk Stuff

Good Practices of Good recruitment consultants

 

Last Weeks Top CRM Articles

 

https://crmbusiness.wordpress.com/2014/07/04/hosks-top-crm-2013-articles-of-the-week-4th-july-2014/