Exception while trying to execute AsyncOperationId: The request failed with HTTP status 401: Unauthorized.

This error message appears when you are trying to import a file but something is going wrong. There are multiple reasons for this error message to show up. Some reasons which I found on the web include:

- See if the account that your Asynchronous Service runs under can authenticate with your SQL Server Service.
- If you're using multiple servers, look at something called a Service Principal Name (or SPN) which is required when you are running the SQL Server service under a non-local system account. This is required so that the SQL Server service account can allow clients to identify and authenticate the service using Kerberos authentication.
- Check if there is an "&" in the file name
- On Windows 2008 with IFD this might be the cause: http://support.microsoft.com/kb/950100.
- Make sure your FriendlyName and UniqueName is the same. See more info on
this here.
- In the DeploymentProperties table in the MSCRM_CONFIG database check the following settings: 'AsyncSdkRootDomain', 'ADSdkRootDomain' and 'ADWebApplicationRootDomain'

All of these didn't help me solve my issue. Apparently somehow the security settings within IIS have been changed. Since this is an IFD deployment, I did expect the anonymous access to be true, but apparently also basic authentication was set instead of windows integrated security. This has been done on the folder MSCRMServices within IISManager, but this can be the case on only the folder 2007 or even the CrmService.asmx file as well.

I hope this helps you solve your issue as well!

Ronald

Complete traced error message:


at AsyncOperationCommand.Execute(AsyncEvent asyncEvent)
at AsyncHostHandler.Handle(AsyncEvent asyncEvent)
at PoolHandler.ProcessAsyncEvent(AsyncEvent asyncEvent)
at PoolHandler.InvokeHandlerInPool(Object state)
at _ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at _ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at _ThreadPoolWaitCallback.PerformWaitCallback(Object state)
>Exception while trying to execute AsyncOperationId: {5DF1A151-3499-DE11-AD3D-4EF819DD5612} AsyncOperationType: 10 - System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at Microsoft.Crm.SdkTypeProxy.CrmService.Execute(Request Request)
at Microsoft.Crm.Asynchronous.SdkTypeProxyCrmServiceWrapper.Execute(Object request)
at Microsoft.Crm.Workflow.WorkflowContext.IsCrmUIWorkflow(Guid activationId)
at Microsoft.Crm.Asynchronous.WorkflowOperation.InternalExecute(AsyncEvent asyncEvent)
at Microsoft.Crm.Asynchronous.AsyncOperationCommand.Execute(AsyncEvent asyncEvent)



This time I request some help from you

And now, for something completely different. Usually, at least I hope, you can find the answer to your questions on this blog, but this time I would like to ask you guys for a favor. I’m looking for a sponsor.

My little sister Iris Lemmen, 20, doesn’t share my passion for Dynamics CRM. Instead her passion is with Judo. She’s awfully good at it as she has become the Dutch champion for three times. Now she’s working hard to get the European title. In order to achieve this she trains six times a week and spends many days abroad for training camps. Usually my parents are the biggest sponsors for these costs.

Now she has the opportunity to go to the place where Judo has started long ago. She has been invited to visit the Kodokan. This is where Jigoro Kano in 1882 founded his own style Judo. These days this place is still known as the most impressive and educative location for Judo fanatics. She will spend almost two weeks in Japan for training and visit a Grand Slam tournament. After the tournament she will train with the Judokas of the tournament. This means she will be training with the world class of Judo.

As you can imagine, this is a great opportunity she definitely wants to utilize. Unfortunately Japan is one of the most expensive countries in the world; the Japanese readers can confirm that. This is why Iris does need sponsors for this training camp. Of course my parents, I and other relatives are sponsoring her, but we cannot cover all costs. The expectation is that this trip will cost €2.500,-, of which my parents will cover the flight costs. Together with the other sponsors we collected in total almost €1.000,- already. Who can help us to get my sister fly to Japan in the first week of December?

Feel free to post a comment if you are interested in sponsoring Iris. Please let me know who to contact. It would be awesome if you can help me this time, and it offers a way of getting your name connected to one of the Judo champions of the future!


Yep, that's me with Iris!

Next time I'll post about CRM again :)



Close Campaign Response window

Did you ever notice that you will get an warning message when you close a new Campaign Response window? The message you will get is:


Are you sure you want to navigate away from this page?
Your changes have not been saved. To stay on the page so that you can save your changes, click Cancel.
Press OK to continue, or Cancel to stay on the current page.
OK Cancel

You do get this message because Microsoft is automatically filling the Received On attribute. This does set the modified flag on this attribute and the close screen event will recognize this flag. To remove the flag, you will need to reset the value for Received On by using a very simple script like this:

//Receivedon is automatically filled. Setting this value to null prevents a warning when closing the screen.
crmForm.all.receivedon.DataValue = null;

When you bind this script to the OnLoad, you will need to keep in mind that the receivedon won't be automatically filled. You can also look into binding this script to the close window event which will be a bit harder. I'm sure that's possible, who will creat this script for the community?



Update owner in Plugin

Here's a code snippet that will help you to update the owner of a record in a plug-in. This code should run in a POST plug-in:


SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type = SecurityPrincipalType.User;

// PrincipalId is some known Guid belonging to the user or team that will own this record.
assignee.PrincipalId = new Guid("476E234C-5E15-DE11-80BA-000C297AF856");

// Create the target object for the request.
TargetOwnedAccount target = new TargetOwnedAccount();

// Set the properties of the target object.
// EntityId is some known Guid belonging to the account that is being assigned to the user.
target.EntityId = id;

// Create the request object.
AssignRequest assign = new AssignRequest();

// Set the properties of the request object.
assign.Assignee = assignee;
assign.Target = target;

// Execute the request.
ICrmService service = context.CreateCrmService(true);
try
{
AssignResponse assignResponse = (AssignResponse)service.Execute(assign);
}
catch (Exception ex)
{
//TODO: Exceptionhandling
}


Have fun copy and pasting :)



Links in e-mail templates

It is not so hard to get a link in a CRM template, but to hide the link behind your custom text is more difficult. It is possible to do so though. I noticed a small post in the communities by my fellow MVP Adi Katz in which he explains how you can do this. This post does deserve a bit more attention so that's why I am copying the content in this blog post. And now I can find it back as well :)

Adi Katz:
You need to create a new text attribute (e.g. new_workflowhref ) that holds an entire Anchor HTML tag with the HREF property set to the desired link.

Here is a simple example:


<a href=”http://[server]:[port]/[organization name]/userdefined/edit.aspx?etc=10016&id=40f03814-8544-dd11-b4d5-0003ff230264”>click here for more information</a>

You need to set this attribute on a post create event using a plug-in OR you might use Ajax to set this attribute when the form returns after creation e.g.

crmForm.FormType == 2 && crmForm.all.new_workflowhref.DataValue == null

Insert the new_workflowhref field inside the email body. The workflow should run when the new_workflowhref changes.

Cheers,
Adi



Document your CRM installation

Everybody knows the importance of documentation of a project. Thanks to Merijn van Mourik and some other guys there is a tool which can help you documenting your solution. This is a free tool which you can download from Codeplex: CRM 4 documentation.

If you want to use this tool on a standalone machine or a machine without internet connection, then you should download and install the following files first:

vstor30.exe
vstor30sp1-KB949258-x86.exe

I do know that this is not a new tool, but not everybody heard about this before. Happy documentation!



Action Microsoft.Crm.Config.Client.InstallPstAction failed

While installing the Outlook Client, there is one error that appears to be popping up more than others:


Action Microsoft.Crm.Config.Client.InstallPstAction failed.
LaunchOutlookInstallerProcess failed.

There are some blog posts which offer solutions to this error message. If you have this message, try the following:
- Run %windir%\system32\fixmapi.exe
- Reinstall the client
- Install latest rollup of the Dynamics CRM for Outlook client (same version as on server)

Or look at the following blogs:
- http://blogs.msdn.com/crm/archive/2009/05/29/troubleshooting-the-microsoft-dynamics-crm-client-for-outlook.aspx
- http://blogs.msdn.com/mscrmfreak/archive/2006/06/12/627955.aspx

Now these solutions didn't fix the error for one of our clients. Thanks to my colleague Wouter de Nooij we solved this by setting the Microsoft Office language to English. Then redo the configuration (using Start > Microsoft Office > Microsoft Office Tools > Microsoft Office 2007 Language Settings). After that the configuration succeeded. Resetting the language setting to Dutch did not result into problems, so all is well now.

Please let me know if you find other solutions for this error message!