dynamics crm - In CRM 2011 how to create a record and associate it in the same ExecuteMultipleRequest -


i'm struggling find way use executemultiplerequest create record , associate other records @ same time. far i've been successful in first creating record, , in request set associations.

with code throws exception requires target (which need have been submitted create record , id)

private associaterequest getconfigurationrequest(variabledatarequestmodel receivedrequest) {     var configurationrelationship = new relationship(configurationrelationshipname);                 var configurationentities = new entityreferencecollection(new entityreference[]{new entityreference(configurationentitylogicalname,new guid(receivedrequest.configurationid))});                             var rtn = new associaterequest() {  relatedentities = configurationentities, relationship = configurationrelationship };     return rtn; } 

the way achieve executemultiplerequest specify id of new record before create record:

guid accountid = new guid("c85dca5d-6520-4436-a5f6-178b633af819");  entity myaccount = new entity("account"); myaccount["name"] = "test account"; entity.id = accountid; // ... entityreferencecollection relatedentities = new entityreferencecollection(); relatedentities.add(new entityreference("account", accountid)); 

specify id permitted not suggested.


Comments