DynamicEntity ObjProject = GetDynamicEntity(crmService, "new_timesheet", new Guid("{21CCFA77-FFF8-DD11-AE96-0003FFD751E0}"));
public static DynamicEntity GetDynamicEntity(ICrmService crmService, string strEntityName, Guid EntityGuid)
{
try
{
#region Retrieve Entity Record Dynamically
// Create the retrieve target.
TargetRetrieveDynamic targetRetrieve = new TargetRetrieveDynamic();// Set the properties of the target.
targetRetrieve.EntityName = strEntityName;
targetRetrieve.EntityId = EntityGuid;// Create the request object.
RetrieveRequest retrieve = new RetrieveRequest();
// Set the properties of the request object.
retrieve.Target = targetRetrieve;
retrieve.ColumnSet = new AllColumns();
// Indicate that the BusinessEntity should be retrieved as a DynamicEntity.
retrieve.ReturnDynamicEntities = true; // Execute the request.
RetrieveResponse retrieved = (RetrieveResponse)crmService.Execute(retrieve);// Extract the DynamicEntity from the request.
DynamicEntity entity = (DynamicEntity)retrieved.BusinessEntity;
return entity;#endregion
}
catch (System.Web.Services.Protocols.SoapException ex)
{
throw new System.Exception(ex.Detail.InnerText);
}
catch (Exception ex)
{
throw new System.Exception(ex.Message);
}
}
0 comments:
Post a Comment