Hello,
You will be able to build the functionality you need using the Portal Connector API. CrmConnectionManager in the Crm namespace has the functionality you need and should be a good starting point. The code below will give you some idea on how to create, retrieve and delete data from CRM using API. If you have any further questions please contact TPC support team. We will be glad to assisst you.
...
using Microsoft.Xrm.Sdk;
using pavliks.PortalConnector.Crm;
using pavliks.PortalConnector.Crm.Attributes;
using pavliks.PortalConnector.Crm.Connection;
...
public Guid CreateContact(string firstName, string lastName, string email)
Entity contactEntity = new Entity("contact");
contactEntity["firstname"] = firstName;
contactEntity["lastname"] = lastName;
contactEntity["emailaddress1"] = email;
using (var connManager = new CrmConnectionManager())
{
ICrmConnection connection = connManager.Connection;
if (connection is CrmEmptyConnection)
throw new Exception("Unable to connect to Dynamics CRM.");
else
return connection.Create(contactEntity);
}
return Guid.Empty;
}
public void LoadContacts()
EntityCollection data;
// Fetch XML for retrieving contacts
string fetchXML = "<fetch version=\"1.0\" output-format=\"xml-platform\" mapping=\"logical\"><entity name=\"contact\"><attribute name=\"firstname\" /><attribute name=\"lastname\" /><attribute name=\"emailaddress1\" /><attribute name=\"contactid\" /></entity></fetch>";
using (var connManager = new CrmConnectionManager())
{
ICrmConnection connection = connManager.Connection;
if (connection is CrmEmptyConnection)
throw new Exception("Unable to connect to Dynamics CRM.");
else
data = connManager.Connection.RetrieveMultiple(new FetchExpression(fetchXML));
}
if (data != null)
foreach (Entity entity in data.Entities)
{
// some processing here
}
}
public void DeleteContact(Guid entityID, string entityName)
{
using (var connManager = new CrmConnectionManager())
{
if (connManager.Connection is CrmEmptyConnection)
throw new Exception("Unable to connect to Dynamics CRM.");
else
connManager.Connection.Delete(entityName, entityID);
}
}
...