Monday, February 16, 2009

Retrieve Dynamic Entity Records Example



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);
}
}

5 comments:

Sandip R Patel said...

How can we get collection of dynamic entities?

Dynamics 365 Solution Architect | Azure / ALM/DevOps | Power Platform said...

Sandeep,

http://mscrm-developer.blogspot.com/2009/04/retrieve-multiple-dynamic-entity.html

This is the URL.
Hope it will help you.

Thanks,
Ranjit

Dynamics 365 Solution Architect | Azure / ALM/DevOps | Power Platform said...

Hi,


Here is the link for "Retrieve Multiple Dynamic Entity Records Example"


http://mscrm-developer.blogspot.com/2009/04/retrieve-multiple-dynamic-entity.html

Thanks,
Ranjit

dinesh said...


Thanks to the admin you have spend a lot for this blog I gained some useful info for you. Keep doing.
microsoft dynamics crm training institutes in chennai
microsoft dynamics training
CCNA Training in Chennai
Salesforce Training in Chennai
gst classes in chennai
microsoft crm training

Devi said...

Very nice informative blog. Actually it's great article. Thanks for sharing unique content. oracle training in chennai