dump custom entity to tracelog dynamics crm 365 ce online c# extension code example
Example 1: dump custom entity to tracelog dynamics crm 365 ce online c# extension
EntityReference entityReference = new EntityReference("account", Guid.Parse("608DA112-2681-4967-B30E-A4132321010A"));
string[] columnNames= new string[] { ..list of fields.. };
service.Retrieve(entityReference.LogicalName, entityReference.Id, new ColumnSet(columnNames));
service.Retrieve(entityReference, columnNames);
public static Entity Retrieve(this IOrganizationService service, EntityReference entityReference, string[] columnNames)
=> service.Retrieve(entityReference.LogicalName, entityReference.Id, new ColumnSet(columnNames));
Example 2: dump custom entity to tracelog dynamics crm 365 ce online c# extension
Guid entityReferenceId = account1.Contains("primarycontact")
? ((EntityReference)account1["primarycontact"]).Id
: Guid.Empty;
if (entityReferenceId == Guid.Empty)
{
if (account2.Contains("primarycontact"))
{
account2["primarycontact"] = null;
}
}
else
{
if (account2.Contains("primarycontact"))
{
account2["primarycontact"] = new EntityReference("contact", entityReferenceId);
}
else
{
account2.Attributes.Add("primarycontact") = new EntityReference("contact", entityReferenceId);
}
}