Last active
August 1, 2017 13:13
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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