我为慈善机构工作,我们希望使用Dynamics 365来支持我们的筹款团队。我们创建了一个与“联系”实体具有N:N关系的“筹款活动”实体(在我们的组织中重命名为“个人”。我在每个实体上都有一个子网格,以便我们可以从联系人记录中添加联系人到事件或者从事件记录中。 我们需要能够向每个注册参加活动的人发送电子邮件,以祝他们在活动前好运。我创建了一个针对'筹款活动'实体的工作流程,在活动开始日期前7天运行,但是当我测试这个时,系统作业显示“错误;需要注意”,当我查看该过程时,它会显示一条消息“电子邮件必须至少有一个收件人才能发送。“ Process error image 在WF发送电子邮件属性中,我尝试在TO字段中使用“联系人”和“命名联系人(查找)”列表(请参见下面的屏幕截图),但我得到了两个选项的相同结果。 To line option list image 我的测试事件有2个个人(联系人)链接到它,我可以在事件记录的子网格中看到它们,但我似乎无法向他们发送电子邮件。 以下是失败过程的详细信息:
Plugin Trace:
[Microsoft.Xrm.Sdk.Workflow: Microsoft.Xrm.Sdk.Workflow.Activities.SendEmail]
[SendEmailStep1]
Error Message:
Unhandled Exception:
System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The e-mail must have at least one recipient before it can be sentDetail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ActivityId>9161cfb2-308e-4b19-af39-b859a78f132f</ActivityId>
<ErrorCode>-2147218684</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>The e-mail must have at least one recipient before it can be sent</Message>
<Timestamp>2017-03-31T11:07:27.6562583Z</Timestamp>
<ExceptionSource i:nil="true" />
<InnerFault>
<ActivityId>9161cfb2-308e-4b19-af39-b859a78f132f</ActivityId>
<ErrorCode>-2147218684</ErrorCode>
<ErrorDetails xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>The e-mail must have at least one recipient before it can be sent</Message>
<Timestamp>2017-03-31T11:07:27.6562583Z</Timestamp>
<ExceptionSource i:nil="true" />
<InnerFault i:nil="true" />
<OriginalException i:nil="true" />
<TraceText i:nil="true" />
</InnerFault>
<OriginalException i:nil="true" />
<TraceText>[Microsoft.Xrm.Sdk.Workflow: Microsoft.Xrm.Sdk.Workflow.Activities.SendEmail]
[SendEmailStep1]
</TraceText>
</OrganizationServiceFault>
at Microsoft.Crm.Workflow.Services.SendEmailActivityService.Execute(ActivityContext executionContext, SendEmail sendEmail)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
是否有可能做我正在尝试使用开箱即用的功能?如果是这样,我错过了什么? 谢谢, 保罗
答案 0 :(得分:1)
您在此处尝试实现的目标不仅仅是配置。您有这个错误,因为您没有引用子网格中的联系人,而是指一个名为&#34的联系人;联系人&#34;这可能是空的,导致错误。唯一的方法是创建一个自定义工作流活动,它将获得所有必要的联系人并将其放入您的电子邮件中。如果您不想编码,可以使用Aiden Kaskela的工作流程元素来实现您的目标:
答案 1 :(得分:0)
我们做了类似的事。
在电子邮件预操作中注册插件创建消息&amp;在那里有这个逻辑。
这将在电子邮件To
列表中添加N:N联系人交叉实体的收件人。
ConditionExpression frCondition1 = new ConditionExpression();
ConditionExpression frCondition2 = new ConditionExpression();
EntityCollection frResponse = new EntityCollection();
EntityCollection toOwner = new EntityCollection();
toOwner = targetEntity.GetAttributeValue<EntityCollection>("to");
frCondition1 = CreateConditionExpression("parentIdcolummn", ConditionOperator.Equal, new string[] { parent.Id.ToString() });
frCondition2 = CreateConditionExpression(statuscode, ConditionOperator.Equal, new object[] { 1 });
ConditionExpression[] conditions = new ConditionExpression[] { frCondition1, frCondition2 };
FilterExpression filterExpression = new FilterExpression();
filterExpression.Conditions.AddRange(conditions);
filterExpression.FilterOperator = LogicalOperator.And;
QueryExpression queryExpression = new QueryExpression();
queryExpression.ColumnSet = GenerateColumnSet("columnNames");
queryExpression.EntityName = "entityName";
queryExpression.Criteria = filterExpression;
queryExpression.NoLock = true;
frResponse = (EntityCollection)service.RetrieveMultiple(queryExpression);
if(frResponse != null && frResponse.Entities.Count > 0)
{
//Adding all FRs in the email
foreach (Entity FilingRep in frResponse.Entities)
{
Guid frGuid = ((EntityReference)FilingRep["contactLookupfieldname"]).Id;
Entity toParty = new Entity("activityparty");
toParty[ActivityParty.ActivityPartId] = new EntityReference("contact", frGuid);
ToOwner.Entities.Add(toParty);
}
}
targetEntity[EmailEntityAttributeName.To] = toOwner;