CRM2016 – Wrong height Layout inside a WebResource on Form

We have a HTML Page as a webresource inside our CRM. In this webPage there are two dropdownlist. We need to manage a Due date.
This was created in the past for CRM2011 and all layout worked always in right way.

Capturecrm2011

CRM2011 – Right layout

We upgrade our CRM to CRM2016 and we start with layout problem:

Capture11

CRM2016 – Wrong layout

 

I must insert this piece of code inside my webresource:

if (typeof parent.$ !== 'undefined') //Check for CRM2011 version. Work only on CRM2015/CRM2016
{
   parent.$( document ).ready(function() {
           var elem = parent.$('#WebResource_duedate');
           elem.height('24px');
   });
}

This code works on DOM directly and change the height. The result is:
Capturenew

CRM2016 – Right Layout

CRM2013 – Save and refresh an entity without postback

Today I had a strange problematic for my client: I needed to update an hidden field without that the user niticing it. I found a solution on this blog: http://www.hebbink.com/post/2015/06/22/saving-and-refreshing-a-crm-entity-form-without-postback

function SaveAndRefresh() {
    Xrm.Page.getAttribute("myAttributeName").setValue(null);
    Xrm.Page.data.refresh(true);
}

Thanks a lot for this great solution!

CRM2016 – Check if Turbo Forms are enabled

Inside our form we need to check if “Turbo Form” is enabled or not. There are an usupported way to check this:

var turboFormsEnabled = Xrm.Internal.isTurboForm();

Xrm.Internal function: this function calls Mscrm.Utilities.isTurboForm which then checks window.IsTurboForm; if window.IsTurboForm is undefined, returns false, otherwise true.

CRM2016 – Update lookup field bug

2007_microsoft_dynamics_crmI encountered a strange behavior after upgrading on premise CRM 2013 to 2016 version.

In the account form after I set the value of the custom lookup field (lookup to custom Country entity) I got javascript error:

SCRIPT5007: Unable to get property ‘trim’ of undefined or null reference

After some hours of debugging I removed all javascript code. Then I copied the example from SDK, the error was still there.

Investigating the setValue method I discovered, that something like “internalOnChange” was called. I suspect this method was called because there are some filtered lists in the page that depend on the value of this field.

Long story short, there are two ways to fix this:

Method 1:
Go to Settings-Administration-System settings. All the way down at the end of the page enable “Use legacy form rendering”.

This will definitely slow down form loading.

Method 2:
The code deep down in the out-of-the-box CRM javascript libraries the script wants to parse the attribute type, but it is not there. The value should be “lookup” and you should pass it in the object when calling setValue.

//Create the lookup value object
var lookupReference = [];
lookupReference[0] = {};
lookupReference[0].id = "{a0c68c89-9752-e311-93f9-00155d78043f}";
lookupReference[0].entityType = "new_entityname";
lookupReference[0].name = "Display name";

//Magic happens here
lookupReference[0].type = "lookup";

//Update the lookup field
Xrm.Page.getAttribute("new_entitynameid").setValue(lookupReference);

CRM2016 – Two Options field bug

Today I found a bug inside CRM2016; I upgraded CRM2013 to CRM2016 and I have some Form Legacy.

On Form I have a field with name “Select Product”. This field has two value to choose:

  1. Existing
  2. Write In

field_error2

When I open this form, I have always “FALSE” as default value:

field_error1

I tried to delete and re-create but I always have the same problem. I don’t find a solution but I found a workaround in javascript: I created a method to manually force the change value:

attribute attr1 = Xrm.Page.getAttribute("nameattribute");
if (attr1 != null)
{
attr1.setValue(1);
attr1.setValue(0);
}

field_error3
 

I don’t understand if this is a CRM2016 problem or it is my problem…

 

CRM2016 Unable to get property ‘ClientVariables’ of undefined or null reference

2007_microsoft_dynamics_crmWhen I tried to open a Task in the Activity inside CRM2016 I have a blank screen.

Problem

In javascript I have error on
Unable to get property ‘ClientVariables’ of undefined or null reference
I tried to open a task with Administrator user but I have alway the same problem.
I used the CRM diagnostic tool and I found this error inside the log:

2016-03-09 14:34:28.823] Process: w3wp |Organization:5f48a1a7-88df-e511-93f8-00155d50690f |Thread: 20 |Category: Application |User: 00000000-0000-0000-0000-000000000000 |Level: Verbose |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | RetrieveCommand.Execute ilOffset = 0x2
Post-Platform Request: Retrieve
[2016-03-09 14:34:28.823] Process: w3wp |Organization:5f48a1a7-88df-e511-93f8-00155d50690f |Thread: 20 |Category: Application |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | Util.TraceMessage ilOffset = 0x79
UserId ({D4940804-3DF9-E211-92B5-00155D05B20C}): FormDescriptor: Creating new form descriptor. LCID: 1033. EntityType: 4212. FormType: Main. FormId: b62ce022-cc0f-4c8c-bb29-21948f70dc74
[2016-03-09 14:34:28.839] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Application |User: 00000000-0000-0000-0000-000000000000 |Level: Error |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | MainApplication.Application_Error ilOffset = 0x9F
Request d2devcrm10/.../layout.aspx;formid=16654191-19ad-48ca-9e46-c4b4fbdad76f&formts=3085142&hash=EA1390550CBFB3F9BE24FC68C3374613C730841943680D5FA152B67E73B4C7B9&isPreview=False&isTurboForm=False&outlook=False failed with exception System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. --- System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Crm.Application.CellDescriptor..ctor(XmlNode formNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab, Boolean isInFirstColumn, Boolean isInLastColumn)
at Microsoft.Crm.Application.CellCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.RowDescriptor..ctor(IXPathNavigable node, EntityMetadata entityMetadata, FormDescriptor formDescriptor, Boolean rowVisible, TabDescriptor containerTab)
at Microsoft.Crm.Application.RowCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, Int32 sectionColumns, TabDescriptor containerTab)
at Microsoft.Crm.Application.SectionCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.ColumnDescriptor..ctor(XmlNode columnNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.ColumnCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.TabDescriptor..ctor(XmlNode formNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor)
at Microsoft.Crm.Application.TabCollection..ctor(XmlNode formNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor)
at Microsoft.Crm.Application.FormDescriptor.InitializeObjectModel(XmlNode formNode, EntityMetadata entityMetadata, FormType formType)
at Microsoft.Crm.Application.FormDescriptor.Initialize(EntityMetadata entityMetadata, XmlNode formXml, Guid formId, FormType formType)
at Microsoft.Crm.Application.FormDescriptor..ctor(EntityMetadata entityMetadata, XmlNode formXml, Guid formId, FormType formType, Boolean isUserForm, Boolean isActive, IOrganizationContext context)
at Microsoft.Crm.Application.FormDescriptor..ctor(Int32 typeCode, XmlNode formXml, Guid formId, FormType formType, Int64 versionNumber, FormPresentationMode formPresentation, Boolean isActive, IOrganizationContext context)
at Microsoft.Crm.Application.Forms.FormDescriptorLoader.LoadCacheData(FormDescriptorCacheKey key, IOrganizationContext context)
at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey key, IOrganizationContext context)
at Microsoft.Crm.Application.Forms.FormDescriptorCache.GetFormDescriptor(Guid formId, IOrganizationContext context)
at Microsoft.Crm.Application.Platform.AppFormFilter.<GetFilteredFormListb__4(Guid formId)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.Crm.Application.Controls.AppFormSelector.ConfigureHeader()
at Microsoft.Crm.Application.Components.UI.CrmUIControlBase.ConfigureControlInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
[2016-03-09 14:34:28.854] Process: w3wp |Organization:5f48a1a7-88df-e511-93f8-00155d50690f |Thread: 20 |Category: Application |User: 00000000-0000-0000-0000-000000000000 |Level: Error |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ErrorInformation.LogError ilOffset = 0x17
MSCRM Error Report:
--------------------------------------------------------------------------------------------------------
Error: Exception of type 'System.Web.HttpUnhandledException' was thrown.

Error Message: 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.

Error Details: Exception of type 'System.Web.HttpUnhandledException' was thrown.

Source File: Not available

Line Number: Not available

Request URL: d2devcrm10/.../layout.aspx;formid=16654191-19ad-48ca-9e46-c4b4fbdad76f&formts=3085142&hash=EA1390550CBFB3F9BE24FC68C3374613C730841943680D5FA152B67E73B4C7B9&isPreview=False&isTurboForm=False&outlook=False

Stack Trace Info: [NullReferenceException: Object reference not set to an instance of an object.]
at Microsoft.Crm.Application.CellDescriptor..ctor(XmlNode formNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab, Boolean isInFirstColumn, Boolean isInLastColumn)
at Microsoft.Crm.Application.CellCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.RowDescriptor..ctor(IXPathNavigable node, EntityMetadata entityMetadata, FormDescriptor formDescriptor, Boolean rowVisible, TabDescriptor containerTab)
at Microsoft.Crm.Application.RowCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, Int32 sectionColumns, TabDescriptor containerTab)
at Microsoft.Crm.Application.SectionCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.ColumnDescriptor..ctor(XmlNode columnNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.ColumnCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.TabDescriptor..ctor(XmlNode formNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor)
at Microsoft.Crm.Application.TabCollection..ctor(XmlNode formNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor)
at Microsoft.Crm.Application.FormDescriptor.InitializeObjectModel(XmlNode formNode, EntityMetadata entityMetadata, FormType formType)
at Microsoft.Crm.Application.FormDescriptor.Initialize(EntityMetadata entityMetadata, XmlNode formXml, Guid formId, FormType formType)
at Microsoft.Crm.Application.FormDescriptor..ctor(EntityMetadata entityMetadata, XmlNode formXml, Guid formId, FormType formType, Boolean isUserForm, Boolean isActive, IOrganizationContext context)
at Microsoft.Crm.Application.FormDescriptor..ctor(Int32 typeCode, XmlNode formXml, Guid formId, FormType formType, Int64 versionNumber, FormPresentationMode formPresentation, Boolean isActive, IOrganizationContext context)
at Microsoft.Crm.Application.Forms.FormDescriptorLoader.LoadCacheData(FormDescriptorCacheKey key, IOrganizationContext context)
at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey key, IOrganizationContext context)
at Microsoft.Crm.Application.Forms.FormDescriptorCache.GetFormDescriptor(Guid formId, IOrganizationContext context)
at Microsoft.Crm.Application.Platform.AppFormFilter.<GetFilteredFormListb__4(Guid formId)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.Crm.Application.Controls.AppFormSelector.ConfigureHeader()
at Microsoft.Crm.Application.Components.UI.CrmUIControlBase.ConfigureControlInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

[HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.]
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

[2016-03-09 14:34:28.854] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | FaultHelper.ConvertToFault ilOffset = 0x0
TryConvertToFaultExceptionInternal: exception: System.Web.HttpUnhandledException
[2016-03-09 14:34:28.870] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.DumpExceptionRecursive ilOffset = 0x294
NestingDepth: 24
[2016-03-09 14:34:28.870] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.DumpExceptionToTrace ilOffset = 0x11
----- dump exception/fault tree (TryConvertToFaultExceptionInternal: before) -----
EXCEPTION: 0
Type: System.Web.HttpUnhandledException
Message (65): Exception of type 'System.Web.HttpUnhandledException' was thrown.
StackTrace (605):
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
<<<<< StackTrace:
no PluginTrace
EXCEPTION: 1
Type: System.NullReferenceException
Message (53): Object reference not set to an instance of an object.
StackTrace (4015):
at Microsoft.Crm.Application.CellDescriptor..ctor(XmlNode formNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab, Boolean isInFirstColumn, Boolean isInLastColumn)
at Microsoft.Crm.Application.CellCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.RowDescriptor..ctor(IXPathNavigable node, EntityMetadata entityMetadata, FormDescriptor formDescriptor, Boolean rowVisible, TabDescriptor containerTab)
at Microsoft.Crm.Application.RowCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, Int32 sectionColumns, TabDescriptor containerTab)
at Microsoft.Crm.Application.SectionCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.ColumnDescriptor..ctor(XmlNode columnNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.ColumnCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.TabDescriptor..ctor(XmlNode formNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor)
at Microsoft.Crm.Application.TabCollection..ctor(XmlNode formNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor)
at Microsoft.Crm.Application.FormDescriptor.InitializeObjectModel(XmlNode formNode, EntityMetadata entityMetadata, FormType formType)
at Microsoft.Crm.Application.FormDescriptor.Initialize(EntityMetadata entityMetadata, XmlNode formXml, Guid formId, FormType formType)
at Microsoft.Crm.Application.FormDescriptor..ctor(EntityMetadata entityMetadata, XmlNode formXml, Guid formId, FormType formType, Boolean isUserForm, Boolean isActive, IOrganizationContext context)
at Microsoft.Crm.Application.FormDescriptor..ctor(Int32 typeCode, XmlNode formXml, Guid formId, FormType formType, Int64 versionNumber, FormPresentationMode formPresentation, Boolean isActive, IOrganizationContext context)
at Microsoft.Crm.Application.Forms.FormDescriptorLoader.LoadCacheData(FormDescriptorCacheKey key, IOrganizationContext context)
at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey key, IOrganizationContext context)
at Microsoft.Crm.Application.Forms.FormDescriptorCache.GetFormDescriptor(Guid formId, IOrganizationContext context)
at Microsoft.Crm.Application.Platform.AppFormFilter.<GetFilteredFormListb__4(Guid formId)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.Crm.Application.Controls.AppFormSelector.ConfigureHeader()
at Microsoft.Crm.Application.Components.UI.CrmUIControlBase.ConfigureControlInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
<<<<< StackTrace:
no PluginTrace
InnerException <null
<<<<< EXCEPTION: 1

[2016-03-09 14:34:28.870] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ConvertToFault ilOffset = 0x24
NestingDepth: 24
[2016-03-09 14:34:28.870] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ConvertToFault ilOffset = 0x57
ToSingleFaultUntyped: enter
[2016-03-09 14:34:28.870] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ToSingleFaultUnTyped ilOffset = 0x35
ToSingleFault/FE [2016-03-09 14:34:28.870] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ToSingleFaultUnTyped ilOffset = 0x3A
ToSingleFaultOther: enter
[2016-03-09 14:34:28.870] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ConvertMessageAndErrorCode ilOffset = 0x21
enter: ConvertMessageAndErrorCode: System.Web.HttpUnhandledException
[2016-03-09 14:34:28.870] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Error |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ConvertMessageAndErrorCode ilOffset = 0x221
System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #485A06D2: System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. --- System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Crm.Application.CellDescriptor..ctor(XmlNode formNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab, Boolean isInFirstColumn, Boolean isInLastColumn)
at Microsoft.Crm.Application.CellCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.RowDescriptor..ctor(IXPathNavigable node, EntityMetadata entityMetadata, FormDescriptor formDescriptor, Boolean rowVisible, TabDescriptor containerTab)
at Microsoft.Crm.Application.RowCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, Int32 sectionColumns, TabDescriptor containerTab)
at Microsoft.Crm.Application.SectionCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.ColumnDescriptor..ctor(XmlNode columnNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.ColumnCollection..ctor(XmlNodeList nodes, EntityMetadata entityMetadata, FormDescriptor formDescriptor, TabDescriptor containerTab)
at Microsoft.Crm.Application.TabDescriptor..ctor(XmlNode formNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor)
at Microsoft.Crm.Application.TabCollection..ctor(XmlNode formNode, EntityMetadata entityMetadata, FormDescriptor formDescriptor)
at Microsoft.Crm.Application.FormDescriptor.InitializeObjectModel(XmlNode formNode, EntityMetadata entityMetadata, FormType formType)
at Microsoft.Crm.Application.FormDescriptor.Initialize(EntityMetadata entityMetadata, XmlNode formXml, Guid formId, FormType formType)
at Microsoft.Crm.Application.FormDescriptor..ctor(EntityMetadata entityMetadata, XmlNode formXml, Guid formId, FormType formType, Boolean isUserForm, Boolean isActive, IOrganizationContext context)
at Microsoft.Crm.Application.FormDescriptor..ctor(Int32 typeCode, XmlNode formXml, Guid formId, FormType formType, Int64 versionNumber, FormPresentationMode formPresentation, Boolean isActive, IOrganizationContext context)
at Microsoft.Crm.Application.Forms.FormDescriptorLoader.LoadCacheData(FormDescriptorCacheKey key, IOrganizationContext context)
at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey key, IOrganizationContext context)
at Microsoft.Crm.Application.Forms.FormDescriptorCache.GetFormDescriptor(Guid formId, IOrganizationContext context)
at Microsoft.Crm.Application.Platform.AppFormFilter.<GetFilteredFormListb__4(Guid formId)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.Crm.Application.Controls.AppFormSelector.ConfigureHeader()
at Microsoft.Crm.Application.Components.UI.CrmUIControlBase.ConfigureControlInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
[2016-03-09 14:34:28.870] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ConvertMessageAndErrorCode ilOffset = 0x281
exit: ConvertMessageAndErrorCode: errorCode: 0x80040216; message: System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #485A06D2
[2016-03-09 14:34:28.886] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ToSingleFaultOther ilOffset = 0x2F
ToSingleFaultCommon: enter
[2016-03-09 14:34:28.886] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ToSingleFaultOther ilOffset = 0x2F
no PluginTrace
[2016-03-09 14:34:28.886] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ToSingleFaultOther ilOffset = 0x2F
no CrmExceptionFaults
[2016-03-09 14:34:28.886] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ToSingleFaultCommon ilOffset = 0x183
IncludeCallStack: True
[2016-03-09 14:34:28.886] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ConvertToFault ilOffset = 0x24
NestingDepth: 24
[2016-03-09 14:34:28.886] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ConvertToFault ilOffset = 0x69
ToSingleFaultUntyped: enter
[2016-03-09 14:34:28.886] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ToSingleFaultUnTyped ilOffset = 0x35
ToSingleFault/FE [2016-03-09 14:34:28.886] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ToSingleFaultUnTyped ilOffset = 0x3A
ToSingleFaultOther: enter
[2016-03-09 14:34:28.886] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 20 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Info |ReqId: 7833a3ca-d273-481c-a9fd-1802b2986666 | ExceptionConverter.ConvertMessageAndErrorCode ilOffset = 0x21
enter: ConvertMessageAndErrorCode: System.NullReferenceException

Solution

After check all javascript, disable all javascript,check permissions, etc.
I need to cut the story short but in essence it went – Google, Forums, Google, Coffee, Head scratch, Google.
I opened customization.xml and I searched the event “onload”:

<events>
                <event name="onload" application="true" active="true">
                  <InternalHandlers>
                    <Handler functionName="Mscrm.Form_onload" libraryName="Incident_main_system_library.js" handlerUniqueId="1b5e628c-097e-41dc-a6ab-51fadd5de253" enabled="false">
                      <dependencies>
                        <dependency id="contractid" />
                        <dependency id="contractdetailid" />
                      </dependencies>
                    </Handler>
                  </InternalHandlers>
                  <Handlers>
                    <Handler handlerUniqueId="{1dcd9e64-7711-3a2b-6b55-c66e3bd39a21}" functionName="Winvs.Next.InsuranceBroker.ClientScript._incident_form.onFormLoad" libraryName="winvs_Winvs_Next_Insurance_Broker_ClientScript" enabled="true" passExecutionContext="false" parameters="" />
                  </Handlers>
                </event>
                <event name="onchange" application="true" active="true" attribute="customerid">
                  <InternalHandlers>
                    <Handler functionName="Mscrm.customerid_onchange" libraryName="Incident_main_system_library.js" handlerUniqueId="d806cf5a-b111-40ee-a955-3261d2c7df9b" enabled="true">
                      <dependencies>
                        <dependency id="contractid" />
                        <dependency id="contractdetailid" />
                      </dependencies>
                    </Handler>
                  </InternalHandlers>

So I just changed the enabled=’True’ to false and saved the xml, re-zipped and imported the Solution – Bingo! it worked without error.

Now….. I’m not sure 100% what the story is here, but I have a feeling this is some throw back.

CRM2011 – Errore: The view or chart specified in the dashboard definition is not valid for the specified record type “Entity”

E’ la terza volta che ho questo errore ed ogni volta mi dimentico sempre come risolverlo. Ho deciso di scrivere un post e *tatuarlo” in internet… 🙂

Problema

Quando “linko” una nuova webresource con un FETCH XML custom ad una entity (che sia linkato come webresource nel Navigation Pane o come IFRAME direttamente nell’entità) ricevo il messaggio di errore in oggetto.

Diagnosi

Questo problema è dovuto al GUID errato inserito per la DefaultView. Il GUID inserito è corretto ma il tipo di vista selezionato non è DefaultView.

Soluzione

Aprire dalla Solution l’entità, selezionare la sezione Views, selezionare il link della Default View.

Dal link estrarre il GUID ed inserirlo nella nostra WebResource.

CRM2013 – Multilookup: Modify the code CRM2011

I migrated the solutions from CRM2011 to CRM2013 but I found a big problem with Multilookup: It does not work…  I tryed to use the solution inside this post https://mscrmmindfire.wordpress.com/2014/05/20/crm-2013-manipulate-look-up-to-show-multiple-entity-record/ but does not work..

Customer type Lookups in Dynamics CRM have always been an interesting and powerful feature that allows you to associate records of multiple entities with entities like Cases, Orders, etc. PartyList Lookups are similar to Customer type lookups, except for the fact that it allows you to have access to a vast array of entities. They are generally available in Activities like Appointments, Phone Calls, etc.

Sometime or the other, you might have had the requirement to modify customer type lookup in CRM to restrict records to a particular entity. For example, you might want to restrict the end user from selecting Accounts while placing an Order from the “Customer” Lookup. Well, there’s a way to achieve that in CRM using JavaScript. It isn’t exactly a supported one. But chances of Rollups breaking it is very less.

img1

Things are a bit different in CRM 2013. In CRM 2011 and even CRM 4.o, the DOM was a litte bit different. But CRM 2013 has its own brand new DOM structure. So, the code differs from that of CRM 2011. If you simply want to get to the code to implement, you can move directly to the next section. If you want to know why that code is required, read on.

Consider we want to restrict the Cusom lookup to a specific entity, Account. If you’re using Internet Explorer, press F12 to open up the Developer Tools. Search for “new_testfield_i” and you’ll find something as follows.

img3

Now, this “new_testfield_i” is basically the magnifying glass image in the “TestField” lookup button. It consists some interesting properties that determine what entities will be displayed in the lookup form. However, we are interested in only a handful of them in order to get our job done. They are “lookuptypes”, “lookuptypeIcons”, “lookuptypenames” and “defaulttype”. Having a closer look at them pretty much explains what each property signifies.

So, now that we have identified what needs to be changed where, let’s get to the coding part of it. Basically, the idea here is to append “_i” after the Customer type lookup field name. Once you get that element, change its properties to get the desired result.

If you have followed the earlier section, you’d know why the following code snippet is required and what exactly it does. Just to be on the same page, the following code will allow only “Account” records to be displayed in the “Regarding” lookup field (in the Phone Call entity).

document.getElementById("new_testfield_i").setAttribute("lookuptypes", "1");
document.getElementById("new_testfield_i").setAttribute("lookuptypeIcons", "/_imgs/ico_16_1.gif");
document.getElementById("new_testfield_i").setAttribute("lookuptypenames", "account:1:Account");
document.getElementById("new_testfield_i").setAttribute("defaulttype", "1");

Well, don’t think it’s done yet! Although the above code might work most of the times, you might find it failing sometimes. Why? Because the entire DOM of Dynamics CRM 2013 is loaded in an asynchronous manner. Hence, the point where your script executes, the field “Regarding” might not have been rendered yet! Let’s add this small fix for it to work perfectly.

setTimeout(function() {
document.getElementById("new_testfield_i").setAttribute("lookuptypes", "1");
document.getElementById("new_testfield_i").setAttribute("lookuptypeIcons", "/_imgs/ico_16_1.gif");
document.getElementById("new_testfield_i").setAttribute("lookuptypenames", "account:1");
document.getElementById("new_testfield_i").setAttribute("defaulttype", "1");
}, 1000);

Now, that was if you wanted to restrict a Customer lookup field to a single entity. What do you do if you want to allow multiple entities, and restrict only a few? It’s simple. See the following code to get it.

setTimeout(function() {
document.getElementById("new_testfield_i").setAttribute("lookuptypes", "1,2");
document.getElementById("new_testfield_i").setAttribute("lookuptypeIcons", "/_imgs/ico_16_1.gif?ver=-475068199:/_imgs/ico_16_2.gif");
document.getElementById("new_testfield_i").setAttribute("lookuptypenames", "account:1:Account,contact:2:Contact");
document.getElementById("new_testfield_i").setAttribute("defaulttype", "1");
}, 1000);

The result now is as follows with Account and Contact being the only allowed Entities.

img5