Hi,
I want the Contact field required bases on some conditions,
so I implemented some JavaScript based on some conditions.
On the onSave event for the Case I have the following code:
function ForceRequirement(executionObj)
{
//Check the Responsible Contact field if IS NULL
if (((Xrm.Page.getAttribute("casetypecode").getText() === "Problem") ||
(Xrm.Page.getAttribute("casetypecode").getText() === "Question")) &&
(Xrm.Page.getAttribute("customerid").getValue() !== "Company 1") &&
(Xrm.Page.getAttribute("customerid").getText() !== "Company 2") &&
(Xrm.Page.getAttribute("new_caseslinkedid").getText() === null) &&
(Xrm.Page.data.entity.getIsDirty() === true))
{
if (Xrm.Page.getAttribute("responsiblecontactid").getValue() === null)
{
alert("You must enter a responsible contact for the Case.");
executionObj.getEventArgs().preventDefault();
}
}
}
Works in Internet Explorer but in FireFox we get the following error
when trying to save the Case:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.NullReferenceException: Microsoft Dynamics CRM has experienced
an error. Reference number for administrators or support: #110654D7Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147220970</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>System.NullReferenceException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #110654D7</Message>
<Timestamp>2016-09-08T15:30:57.9840274Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText i:nil="true" />
</OrganizationServiceFault>
The error is based on the Contact field.
Any help will be greatly appreciated
Thanks:
Nick M