DYNAMICS 365 ATTACH A NOTE TO A RECORD WITH C#
To attach a note to to an entity using C#, use the code below. The note entity is “annotation”.
For example, you could attach a note to a case (incident):
To attach a note to to an entity using C#, use the code below. The note entity is “annotation”.
For example, you could attach a note to a case (incident):
string entitytype = "incident"; |
Entity Note = new Entity("annotation"); |
Guid EntityToAttachTo = Guid.Parse("FDA93807-4EF3-E711-80F2-3863BB2E34E8"); // The GUID of the incident |
Note["objectid"] = new Microsoft.Xrm.Sdk.EntityReference(entitytype, EntityToAttachTo); |
Note["objecttypecode"] = entitytype; |
Note["subject"] = "Test Subject"; |
Note["notetext"] = "Test note text"; |
service.Create(Note); |
Sharing sample code to check if a user belongs to a team or not
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | public static bool IsTeamMember(Guid teamID, Guid userID, IOrganizationService service){QueryExpression query = new QueryExpression("team");query.ColumnSet = new ColumnSet(true);query.Criteria.AddCondition(new ConditionExpression("teamid", ConditionOperator.Equal, teamID));LinkEntity link = query.AddLink("teammembership", "teamid", "teamid");link.LinkCriteria.AddCondition(new ConditionExpression("systemuserid", ConditionOperator.Equal, userID));var results = service.RetrieveMultiple(query);if (results.Entities.Count > 0){return true;}else{return false;}} |
Let us see it in action using a sample project. Launching the test harness, we can see the init executed followed by updateView . Makin...