BenPatterson1
BenPatterson1

Reputation: 1482

Bug in CRM? Service Appointment form's javascript causing form save error

Ive narrowed this down... it looks like a bug on the service appointment form but wanted to ask here in case it makes sense to anyone else... recreated in a vanilla CRM, added one javascript file, and attached the javascript function to the onchange of the service.

To recreate yourself, add this javascript to a webresource, then attach that webresource to the serviceappointment form and the onchange of the service. add 2 services to your org if you dont have 2 already. create a new service appointment. choose service A. then choose Service B. save the form. you will see the error.

All the javascript is supported, customizing that form is supported... must be a bug with CRM, right?

Oh, critically, this code works in update rollup 11. Does not work in rollup 12. (I'm usually a strong believer that "select isn't broken", as they say, but this really does look like a bug.)

function OnChange_Service() {
var serviceId;
serviceId = Xrm.Page.getAttribute("serviceid").getValue();

var targetFieldName = 'customers';
var targetFieldEntityType = 'Account';
var targetFieldEntityId = '610BEA47-7B74-E211-B3EB-78E3B511A6C0'; // use a known accountId

Xrm.Page.getAttribute(targetFieldName).setValue(null);

if (serviceId != null) {
    var arrValue;
    arrValue = new Array();
    var targetField = Xrm.Page.getAttribute(targetFieldName);
    if (targetField != null) {
        arrValue[0] = new Object();
        arrValue[0].entityType = targetFieldEntityType;
        arrValue[0].id = targetFieldEntityId;
        arrValue[0].name = "not its real name, but who cares";
        targetField.setValue(arrValue);
    }
} 
}

EDIT: exception/error details:

Exception is (from the trace):

System.FormatException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #1471AD8A: System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException) at System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult& result) at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result) at System.Guid..ctor(String g) at Microsoft.Crm.Application.Platform.AttributeCollection.CreateEnityReferenceFromLookupPropertyValue(String name, Object value, IOrganizationContext context) at Microsoft.Crm.Application.Platform.AttributeCollection.SetEntityProperty(Entity entity, String name, String childAttributeName, Object parentProperty, AttributeMetadata attributeMetadata, Object value, IOrganizationContext context) at Microsoft.Crm.Application.Platform.AttributeCollection.Insert(String name, Object value, Boolean throwIfKeyExists) at Microsoft.Crm.Application.Platform.EntityProxy.SetLookupValueData(XmlNode node) at Microsoft.Crm.Application.Platform.EntityProxy.SetData(XmlNode entityElement) at Microsoft.Crm.Application.Platform.ApplicationEntityCollection.Deserialize(String entitiesXml, String entityType, IOrganizationContext context) at Microsoft.Crm.Application.Platform.EntityProxy.SetData(XmlNode entityElement) at Microsoft.Crm.Application.Forms.EndUserForm.RetrieveParametersForEventDefault() at Microsoft.Crm.Application.Forms.EndUserForm.Initialize(Entity entity) at Microsoft.Crm.Application.Forms.CustomizableForm.Execute(Entity entity, FormDescriptor fd) at Microsoft.Crm.Application.Components.PageHandlers.SchedulableActivityBasePageHandler.ConfigureFormHandler() at Microsoft.Crm.Application.Components.PageHandlers.ServiceAppointmentRecordPageHandler.ConfigureFormHandler() at Microsoft.Crm.Application.Components.PageHandlers.RecordPageHandler.ConfigureFormWrapper() at Microsoft.Crm.Application.Components.Utility.GenericEventProcessor.RaiseEvent(String eventName) at Microsoft.Crm.Application.Controls.PageManager.OnPreRender(EventArgs e) at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The error as displayed to the users is embedded in the form itself as per the screenshot... I have never seen it like that before: Error embedded in form

Upvotes: 2

Views: 1881

Answers (2)

BenPatterson1
BenPatterson1

Reputation: 1482

This is an acknowledged bug. No official timeline for resolution. Microsoft is prioritizing it. They broke the existing functionality in UR11 with UR12.

Upvotes: 1

James Wood
James Wood

Reputation: 17562

Try wrapping the guid in { }.

For example: var targetFieldEntityId = '{610BEA47-7B74-E211-B3EB-78E3B511A6C0}';

This a bit of a guess, I'm basing it on that if you retrieve the id of a lookup the guid is wrapped with { }.

Xrm.Page.getAttribute("new_person").getValue()[0] 
{
    id : "{EB661CDD-8E59-E211-8BC6-4C3A83DBD74D}",
    type : "2",
    name : "James Wood",
    onclick : "openlui(new Sys.UI.DomEvent(event))",
    displayClass : "ms-crm-Lookup-Item",
    data : null,
    typename : "contact",
    category : 0,
    ambiguousRecordsXml : null,
    selected : null
    ...
} 

Upvotes: 0

Related Questions