Hello,
I recently added a customization that would count the number of open opportunities that are related to each account. It works for that function. However, when I open a form to create a new account, I get the following error message:
There was an error with this field's customized event.
Field:window
Event: onload
Error: An exception System.FormatException was thrown while trying to convert input value 'null' to attribute 'opportunity.customerid'. Expected type of attribute value: System.Guid. Exception raised: Should contain 32 digits with 4 dashes.
This is my code. I am using the XrmSvcToolkit:
var opportunityCount;
var ID = Xrm.Page.data.entity.getId();
var fetchXml = "<fetch distinct = 'true' mapping = 'logical' aggregate= 'true' output-format='xml-platform' version = '1.0'>" +
"<entity name = 'account'>" +
"<attribute name = 'accountid' alias = 'acc'aggregate ='countcolumn'/>"+
"<link-entity name = 'opportunity' alias = 'bcc' to = 'accountid' from = 'customerid'>" +
"<filter type = 'and'>" +
"<filter type = 'and'>" +
"<filter type = 'and'>" +
"<condition attribute = 'customerid' operator = 'not-null'/>"+
"<condition attribute = 'statecode' operator = 'eq' value = '0'/>"+
"<condition attribute = 'customerid' operator = 'eq' value = ' " + ID + " '/>"+
"</filter>"+
"</filter>"+
"</filter>"+
"</link-entity>"+
"</entity>"+
"</fetch>";
XrmSvcToolkit.fetch({
fetchXml:fetchXml,
async:false,
successCallback: function(result){
opportunityCount = result.entities[0].acc;
Xrm.Page.getAttribute("new_openopportunities").setValue(opportunityCount);
},
errorCallback: function(error){
throw error;
}
});
}
Any suggestions as to how I can get rid of the error? I've tried to check for null customerid in my fetchxml, but it still returns the same error. Thanks in advance!






