tags:

views:

15

answers:

1

I've been tasked with record customer enquiries through a website directly into the client CRM system. The system is Microsoft CRM and I've previously worked with the supporting web service SDK.

Can anyone please provide me with an example of storing a message entity record through the SDK based on simple contact fields such as email, title, body and created date?

+1  A: 

Not sure if there is already an entity for this. But the process is pretty easy using the SDK. Create an instance of DynamicEntity for the entity you want. Then you add the properties you need. Once the entity has been setup create a TargetCreateDynamic, set its entity property to you new enquiry. Then setup a CreateRequest and finally call Execute on your CrmService instance. Childs play! :)

it might look something like:

DynamicEntity enquiry = new DynamicEntity();
enquiry.Name = "crm_Enquiry";  //Use the name not the display name
StringProperty email = new StringProperty();
email.Name = "email";
email.Value = "[email protected]";
//other props
enquiry.Properties = new Property[] {email,...};

TargetCreateDynamic createEnquiry = new TargetCreateDynamic();
createEnquiry.Entity = enquiry;

CreateRequest create = new CreateRequest();
create.Target = createEnquiry;

CreateResponse response = (CreateResponse) service.Execute(create);
//the response will have the id of the new entity if it succeeds

Hope this helps.

Jake