Search

Retrive Dynamic Entity based on Entity name & Guid

public DynamicEntity retriveEntity(string EntityName, string recordGuid)
{
TargetRetrieveDynamic targetRetrieve = new TargetRetrieveDynamic();

// Set the properties of the target.
targetRetrieve.EntityName = "contact";
targetRetrieve.EntityId = new Guid(rec_guid);

// 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)_svc.Execute(retrieve);

// Extract the DynamicEntity from the request.
DynamicEntity R_entity = (DynamicEntity)retrieved.BusinessEntity;
return R_entity;
}