protected override void Execute(CodeActivityContext activityContext, IWorkflowContext workflowContext, IOrganizationService crmService, ITracingService tracingService) { try { // Get the Source Record URL string sourceRecordUrl = SourceRecord.Get(activityContext); if (string.IsNullOrEmpty(sourceRecordUrl)) { Message.Set(activityContext, "Source Record URL cannot be empty or null"); return; } // Convert Record URL to ER EntityReference sourceRecordEr = EntityRecordUrlHelpers.ConvertRecordUrLtoEntityReference(sourceRecordUrl, crmService); if (sourceRecordEr == null) { Message.Set(activityContext, "Failed to convert record URL into Entity Reference. Please make sure you provide valid record URL"); return; } var recordId = sourceRecordEr.Id; var annotation_isdocument = true; var query = new QueryExpression(sourceRecordEr.LogicalName); query.Distinct = true; query.ColumnSet.AddColumns("createdon"); query.Criteria.AddCondition($"{sourceRecordEr.LogicalName}id", ConditionOperator.Equal, recordId); var queryAnnotation = query.AddLink("annotation", $"{sourceRecordEr.LogicalName}id", "objectid"); queryAnnotation.EntityAlias = "aa"; queryAnnotation.LinkCriteria.AddCondition("isdocument", ConditionOperator.Equal, annotation_isdocument); queryAnnotation.LinkCriteria.AddCondition("filename", ConditionOperator.NotNull); var results = crmService.RetrieveMultiple(query); if (!results.Entities.Any()) { // No attachments found HasAttachment.Set(activityContext, false); return; } // Attachments found HasAttachment.Set(activityContext, true); IsSuccess.Set(activityContext, true); } catch (Exception ex) { IsSuccess.Set(activityContext, false); Message.Set(activityContext, "An error occurred while check for attachments -" + ex.Message); } }
public override int GetHashCode() { int hash = 1; if (Id != 0) { hash ^= Id.GetHashCode(); } if (Title.Length != 0) { hash ^= Title.GetHashCode(); } if (Content.Length != 0) { hash ^= Content.GetHashCode(); } hash ^= awards_.GetHashCode(); if (SenderId != 0) { hash ^= SenderId.GetHashCode(); } if (Sender.Length != 0) { hash ^= Sender.GetHashCode(); } if (CreateTime != 0L) { hash ^= CreateTime.GetHashCode(); } if (OutDateTime != 0L) { hash ^= OutDateTime.GetHashCode(); } if (HasAttachment != 0) { hash ^= HasAttachment.GetHashCode(); } if (MailStatus != 0) { hash ^= MailStatus.GetHashCode(); } return(hash); }