CRM 2011: Hitting Save Quote does not do anything, record not saved

Problem:
As described in the subject line, when user hits the Save/Save & Close button, nothing happens. Quote records are not saved, not even a post back happens when hitting save. We checked all different scenarios and nothing worked as Save event was not triggered.

Configuration:
Users/Team were assigned OOB “Sales Person” roles.
Entity: Quote

Resolution:
Give Product entity a full access to the security role and check saving again. It should work.

Advertisements

XrmToolBox – A Must have tool for CRM/XRM Developers

If you are a seasoned CRM/XRM developer, you must have heard about XrmToolbox. If you have, you can simply ignore this post. BUT if you have not then you MUST read on.

This post is about XrmToolbox (http://www.xrmtoolbox.com/) and its plugins which can improve your efficiency and accelerate overall development speed. I intend to list all the default plugins and provide more details on plugins as and when time permits. So here is a list of plugins which gets installed by default.

 

Continue reading on: XrmToolBox – A Must have tool for CRM/XRM Developers

The Microsoft CRM Email Router service on Local Computer started and then stopped

The Microsoft CRM Email Router Service will not start every time you start it manually from Services and throws an error message “The Microsoft CRM Email Router service on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alerts service.”

Event log entries say:
Event Type: Error
Event Source: MSCRMEmail
Event Category: None
Event ID: 0
Date:
Time:
User:
Computer:
Description:
#16192 – The E-mail Router service could not run the service main background thread. The E-mail Router service cannot continue and will now shut down. System.Configuration.ConfigurationErrorsException: The E-mail router service cannot access system state file Microsoft.Crm.Tools.EmailAgent.SystemState.xml. The file may be missing or may not be accessible. The E-mail Router service cannot continue and will now shut down. —> System.Xml.XmlException: Root element is missing.

This means your Email Router configuration file is corrupted.

You need to go to C:\Program Files\Microsoft CRM Email\Service and delete the Microsoft.Crm.Tools.EmailAgent.SystemState.xml file. Try to re/start the Email Router Service. This should resolve your problem.

CRM 2013: Email Router: The message exceeds maximum supported size

If your email router does not process any emails but your inbox from Email Provider works just fine!?! Check event logs where Email Router is installed. You might see many repeated errors similar to mentioned error here below:

#27938 – An error occurred while checking for email messages to process in mailbox service@gmail.com. Microsoft.Crm.Tools.Email.Providers.EmailException: Error: The message exceeds the maximum supported size.
at Microsoft.Crm.Tools.Email.Providers.ExchangeWSConnector.LogEwsResponseErrorWarning(String message, ResponseClassType responseClassType)
at Microsoft.Crm.Tools.Email.Providers.ExchangeWSConnector.RetrieveMessage(ArrayList ids, Int32 index, ServiceLogger serviceLogger)
at Microsoft.Crm.Tools.Email.Providers.ExchangePollingMailboxProvider.RetrieveNextMessageInternal()
at Microsoft.Crm.Tools.Email.Providers.CrmPollingMailboxProvider.RetrieveNextMessage()
at Microsoft.Crm.Tools.Email.Providers.CrmPollingMailboxProvider.Run()

Check your inbox for the emails with attachments. Find emails with more than expected attachments size per email, take backup (if required) and delete them. Your Email Router should work just fine once this is done!

In my case an email with 100+ MB attachment size was creating an issue.

Happy Troubleshooting!!

CRM 2011, JavaScript: Set Customer Type of Lookup

Lets say you have to set Customer type of Lookup from JavaScript. Here is the code! You just have to set another attribute and you’re done!

Here I have given it in parameters as I had to open form with these parameters auto filled.

var params = {};
params["customerid"] = Xrm.Page.getAttribute("customerid").getValue()[0].id;
params["customeridname"] = Xrm.Page.getAttribute("customerid").getValue()[0].name;
params["customeridtype"] = Xrm.Page.getAttribute("customerid").getValue()[0].entityType;

//Open a new account record
Xrm.Utility.openEntityForm("incident", null, params);

Hope it helps!

CRM 2011, JavaScript: How to add some action after save record?

Hi there!

I recently had a requirement where I had to save the record and open another form once the button is pressed from ribbon.

I added the save JavaScript to the web resource and call it and call other function to open the form. This was not working for me.

Resolution for this:

Add an event on Save action by:

Xrm.Page.data.entity.addOnSave(openAccountForm); // openAccountForm is another function which opens the form
Xrm.Page.data.entity.save();
function openAccountForm() {
    Xrm.Utility.openEntityForm("account");
}

CRM 2011, C#, v3.5: Type ‘OptionSetValue’ with data contract name ‘OptionSetValue:http://schemas.microsoft.com/xrm/2011/Contracts’ is not expected

We already have discussed how to achieve connection of CRM 2011 through .net version 3.5 from below mentioned post. https://consultrikin.wordpress.com/2013/09/20/crm-2011-c-entity-class-redefined-with-net-framwork-3-5-to-connect-crm-2011/

Once this is achieved and you start working on CRUD operations, you will find some run time exceptions thrown like one I have described below.

Type ‘OptionSetValue’ with data contract name ‘OptionSetValue:http://schemas.microsoft.com/xrm/2011/Contracts’ is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.’.  Please see InnerException for more details.

The same thing will be repeated for EntityReference and PicklistAttributeMetadata.

Resolution:

1. Explore the reference.cs from the project in Windows Explorer and open it.

2. Search for class Entity and class EntityReference

3. Add below lines to both partial classes.
     [System.Runtime.Serialization.KnownTypeAttribute(typeof(OptionSetValue))]
     [System.Runtime.Serialization.KnownTypeAttribute(typeof(EntityReference))]

4. Now search for “class OrganizationRequest”.
Add these lines above it:

     [System.Runtime.Serialization.KnownTypeAttribute(typeof(EntityReference))]
     [System.Runtime.Serialization.KnownTypeAttribute(typeof(PrincipalAccess))]
     [System.Runtime.Serialization.KnownTypeAttribute(typeof(OptionSetValue))]

5. Continue adding to classes for which you’re getting these exceptions.

6. Build the solution and run your code again.

Happy Programming! 🙂

CRM 2011, C# Error: The given key was not found in the dictionary.

Many a times unexpected things happen while programming. And in case of Dynamics CRM it “does” happen. Similar issue happened with me today. The subject of the blog post was the annoying error I wanted to get rid off.

The given key was not found in the dictionary.

The first thing comes into the programmers’ mind is that there is nothing in this error and they just need to cross check with the attribute logical names they have used in coding.

To solve this I cross checked each and every attributes from Dynamics CRM and my C# code and not for single but 3-4 times. Finally, I got the idea that all my code is working absolutely correct with nothing wrong in it.

The real issue was not my code but a plugin/workflow activity developed by some other programmer which was registered on the same entity which I was working on. I disabled the step of the workflow activity and the program worked like a charm.

Check for the Plugins or Workflow Activities registered on the same entity to drill down with your issue.

Happy programming!!

Could not load file or assembly ‘microsoft.crm.sdk.proxy’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Hello!!

If you are getting below error when you have deployed your web application which connects to Microsoft Dynamics CRM 2011 online/on premise version.

Could not load file or assembly ‘microsoft.crm.sdk.proxy’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Then probably you have used wrong IIS Application Pool. You might want to change the .Net version of assigned Application Pool to 4.0. And re-run the site.

This should solve the error you were facing.

CRM 2011 Web Page Error: The server was unable to process the request due to an internal error either from ServiceBehaviorAttribute or from the configuration behavior

I was working with a web application which connects to the CRM 2011 Organization Web Service. While developing it through Visual Studio the application was working like a charm! And as soon as I published it to the IIS 7, it began showing me following error and stack trace.

The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ServiceModel.FaultException: The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[FaultException: The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +4767763
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1725
Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request) +0
Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request) +892
xxxxxxxTool.xxxxxContacts.Page_Load(Object sender, EventArgs e) in C:\Users\Administrator\Desktop\xxxxxxxTool\xxxxxxxTool\xxxxxContacts.aspx.cs:173
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048

Looking at the error details, I was not sure what was wrong with a piece of code I wrote! I didn’t even used .Net Framework 3.0 SDK?!? With some findings on net I found some attributes for ServiceBehaviors that should be added to web.config shown as below.

<behaviors>
  <serviceBehaviors>
    <behavior name="SecurityTokenServiceBehavior">
      <!--The serviceMetadata behavior allows one to enable metadata (endpoints, bindings, services) publishing.
This configuration enables publishing of such data over HTTP GET.
This does not include metadata about the STS itself such as Claim Types, Keys and other elements to establish a trust.-->
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
      <!--Default WCF throttling limits are too low-->
      <serviceThrottling maxConcurrentCalls="65536" maxConcurrentSessions="65536" maxConcurrentInstances="65536" />
    </behavior>
  </serviceBehaviors>
</behaviors>

This was not sufficient as error was still there! I thought I had a problem with my IIS, I reinstalled it! Still there is same error. I checked to the other PCs but the issue persisted. Finally I got the solution by some R&D on IIS part.

Through MSDN I found that the Applications made for CRM or using any web services of CRM 2011 will need the same configuration as CRM App Pool. If the application will not consume more, you can use the same App Pool that CRM 2011 web application uses.

The Similar AppPool created for the application must be running on Classic mode and Identity should be Network Service.

And some authentication settings to the web application developed for the CRM will help the application run without issues on IIS 7. Follow this image for Authentication to web application to set.

Authentication Settings

Authentication Settings

Anonymous Authentication should be Disabled. CRM needs Windows Authentication, Enable it. And there is no need to have a Forms Authentication, Disable it.

After all these settings your application should work as expected.

Happy Troubleshooting!!