I am working on insert and update requests to import contacts through a custom application.
I've written createRequest and is working fine for new inserts but I also wnat to do updates in the same code.
So far i've done this for insert but I am not sure how to enforce update request in it. Please suggest how to proceed for updates?
public override void Input0_ProcessInputRow(Input0Buffer Buffer)
{
int index = 0;
while (Buffer.NextRow())
{
_contacts.Add(GetContactFromBuffer(Buffer));
index++;
// Let's use buffer size 500. CRM allows up to 1000 requests per single call
if (index == 500)
{
ImportBatch();
index = 0;
}
}
ImportBatch();
}
private void ImportBatch()
{
if (_contacts.Count > 0)
{
// Create and configure multiple requests operation
var multipleRequest = new ExecuteMultipleRequest()
{
Settings = new ExecuteMultipleSettings()
{
ContinueOnError = true, // Continue, if processing of a single request fails
ReturnResponses = true // Return responses so you can get processing results
},
Requests = new OrganizationRequestCollection()
};
// Build a CreateRequest for each record
foreach (var contact in _contacts)
{
CreateRequest reqCreate = new CreateRequest();
reqCreate.Target = contact;
reqCreate.Parameters.Add("SuppressDuplicateDetection", false); // Enable duplicate detection
multipleRequest.Requests.Add(reqCreate);
}
ExecuteMultipleResponse multipleResponses = (ExecuteMultipleResponse)_orgService.Execute(multipleRequest);
_contacts.Clear();
}
}
private Entity GetContactFromBuffer(Input0Buffer Row)
{
//Insert mappings here
Entity contact = new Entity("contact");
return contact;
}
Thanks for any help.
*This post is locked for comments
I have the same question (0)