Hi,
I'm trying to use the rest create to create a custom entity and associated entities similar to the way this sample is doing from the MS website..
var account = {}; account.Name = "Test Account Name"; account.Description = "This account was created by the JavaScriptRESTDataOperations sample."; if (primaryContact != null) { //Set a lookup value writeMessage("Setting the primary contact to: " + primaryContact.FullName + "."); account.PrimaryContactId = { Id: primaryContact.ContactId, LogicalName: "contact", Name: primaryContact.FullName }; } //Set a picklist value writeMessage("Setting Preferred Contact Method to E-mail."); account.PreferredContactMethodCode = { Value: 2 }; //E-mail//Set a money value writeMessage("Setting Annual Revenue to Two Million ."); account.Revenue = { Value: "2000000.00" }; //Set Annual Revenue//Set a Boolean value writeMessage("Setting Contact Method Phone to \"Do Not Allow\"."); account.DoNotPhone = true; //Do Not Allow//Add Two Tasksvar today = new Date(); var startDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 3); //Set a date three days in the future.var LowPriTask = { Subject: "Low Priority Task", ScheduledStart: startDate, PriorityCode: { Value: 0} }; //Low Priority Taskvar HighPriTask = { Subject: "High Priority Task", ScheduledStart: startDate, PriorityCode: { Value: 2} }; //High Priority Task account.Account_Tasks = [LowPriTask, HighPriTask]
Here it creates the account and adds 2 tasks to it.
I did a similar thing for my custom entity
var competency = new Object(); competency.amd_Competency = { Id: this.id, LogicalName: 'amd_softindicator' }; competency.amd_CMSId = { Id: cmsId, LogicalName: 'amd_cms' } competency.amd_name = "CMS Competency"; competency.amd_CompetencyLevel = { Id: $(this).find('input[:radio]:checked').val(), LogicalName: 'amd_competencylevel' }; actionArray = new Array(); var actions = $('#actions tr').map(function () { var actionObj = new Object(); actionObj.amd_actiondetail = $('textarea', $(this)).val(); actionArray.push(JSON.stringify(actionObj)); }); competency.amd_amd_individualcompetency_amd_action = actionArray; createRecord(competency, "amd_individualcompetency");
This works fine until i put the creation of the related entities in. The name of the entity relationshiop is correct however I keep getting the message
Error processing request stream. The property name 'amd_amd_individualcompetency_amd_action' specified for type 'Microsoft.Crm.Sdk.Data.Services.amd_individualcompetency' is not valid.
Any help appreciated.
Thanks
Chris