Creating a case with an associated account.
ankitchawla23 opened this issue · 2 comments
Hi,
Can you please tell me how I can create a case with an existing account. Below is the code I tried:
var parent = new Array();
parent[0] = new Object();
parent[0].id = "70AB9DC7-0B21-E611-80DD-5065F38B6122";
parent[0].name = "Account name";
parent[0].entityType = "account";
var createCase = crm.create("incident", {
title: "caseTitle",
customerid: parent
});
Below is the exception I got via the console.
Error: The formatter threw an exception while trying to deserialize the message
: There was an error while trying to deserialize parameter http://schemas.micros
oft.com/xrm/2011/Contracts/Services:entity. The InnerException message was 'Erro
r in line 1 position 10215. Element 'http://schemas.microsoft.com/2003/10/Serial
ization/Arrays:anyType' contains data from a type that maps to the name 'System.
Dynamic:ExpandoObject'. The deserializer has no knowledge of any type that maps
to this name. Consider changing the implementation of the ResolveName method on
your DataContractResolver to return a non-null value for name 'ExpandoObject' an
d namespace 'System.Dynamic'.'.
Please let me know what I am missing here.
Thanks
Hey @ankitchawla23,
The problem here was that the Customer type wasn't implemented yet.
I've just committed a change with this functionality.
Try with this code, please.
// Gets any account in the system
var accounts = crm.retrieveMultiple("account",{});
// get its GUID
var accountId = accounts.rows[0].accountid;
var caseGuid = crm.create("incident",{title:"test", customerid:{id:accountId,type:"account"}});
Let me know if it works,
Cristhian
Closing the issue after adding the functionality