Skip to content

Instantly share code, notes, and snippets.

@gashupl
Last active August 1, 2017 13:13
Show Gist options
  • Save gashupl/ad442fafd7e4dea30d468583887ba301 to your computer and use it in GitHub Desktop.
Save gashupl/ad442fafd7e4dea30d468583887ba301 to your computer and use it in GitHub Desktop.
Metoda pozwalająca na sprawdzenie, czy dla encji o danej nazwie możemy dołączyć aktywności
public bool IsEntityActivitiesRelated(IOrganizationService service, string entityName)
{
var response = service.Execute(new RetrieveEntityRequest
{
EntityFilters = EntityFilters.Relationships,
LogicalName = entityName,
RetrieveAsIfPublished = true
}) as RetrieveEntityResponse;
if (response?.EntityMetadata?.OneToManyRelationships != null)
{
return
response.EntityMetadata.OneToManyRelationships
.Any(r => r.ReferencingEntity == ActivityPointer.EntityLogicalName);
}
else
{
//Handle exception when metadata for the selected entity name cannot be retrieved
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment