Monday, February 16, 2009

Update Dynamic Entity Record Example


public static bool UpdateDynamicEntity(ICrmService Service, DynamicEntity entityName)
{
try
{
    // Create the update target.
    TargetUpdateDynamic updateDynamic = new TargetUpdateDynamic(); 

    // Set the properties of the target.
    updateDynamic.Entity = entityName; 

    //   Create the update request object.
    UpdateRequest update = new UpdateRequest(); 

    //   Set request properties.
    update.Target = updateDynamic; 

    //   Execute the request.
    UpdateResponse updated = (UpdateResponse)Service.Execute(update);

    return true;
}
catch (System.Web.Services.Protocols.SoapException ex)
{                
    return false;
}
catch (Exception ex)
{                
    return false;
}
}

1 comment:

Mahesh said...

Gr8 solution......:)