Hi, in CRM 2013 I need to create a record using javascript/XrmServiceToolkit and this works...
var oStart = Xrm.Page.getAttribute("new_starttime").getValue();
var oEnd = Xrm.Page.getAttribute("new_endtime").getValue();
var oDur = Xrm.Page.getAttribute("new_duration").getValue();
var oDate = Xrm.Page.getAttribute("new_supportdate").getValue();
createCaseNoteRec.attributes["new_starttime"] = { value: oStart, type: "DateTime" };
createCaseNoteRec.attributes["new_endtime"] = { value: oEnd, type: "DateTime" };
createCaseNoteRec.attributes["new_duration"] = { value: oDur, type: "decimal" };
createCaseNoteRec.attributes["new_supportdate"] = { value: oDate, type: "DateTime" };
response = XrmServiceToolkit.Soap.Create(createCaseNoteRec);
if (response != "") {
alert("response = " + response);
}
...and creates an entity record (response is "").
However, I also need to identify the client that this data relates to in the new record and have found that each of the following lines of code...
createCaseNoteRec.attributes["new_clientnameid"] = { value: ClientID, type: "EntityReference" };
or
createCaseNoteRec.attributes["new_clientnameid"] = { value: ClientID, type: "Lookup" };
or
createCaseNoteRec.attributes["new_clientnameid"] = { value: ClientID, type: "System.Guid" };
...returns a response of "undefined" & no record is created. If I code it as...
createCaseNoteRec.attributes["new_clientnameid"] = { value: ClientID, type: "string" };
...a record is created but the response is 50b01cde-5837-e511-a43b-0050569e2d5a and the client is not identified.
The "ClientID" variable is populated with the GUID of the client in one form (a lookup field) and the "new_clientnameid" field is a matching lookup in another form.
It seems to me that the issue is to do with the "type" i.e. { value: ClientID, type: "???????" } ...but I can't work out what it should be.
Had this working in CRM 4 but can't get it to work in CRM 2013.
Any suggestions appreciated.
Regards, Doug.