我开发了一个状态机工作流程,这些工作流程正常工作。虽然这是工作,但用户抱怨用工作流任务电子邮件轰炸,这些电子邮件与他们的团队没有任何关系。在Doc Lib中我正在执行工作流程,有一列列出每个团队的应用程序工作。是否有一种方法可以从此字段中获取信息和路由到正确的组。这将是动态的,所以列值可能会改变。该列是一个下拉字段(,您无法从...中检索信息,但我认为),但我创建了一个计算的字段,以从下拉下来检索信息所以它将是在静态列中。此外,我创建了一个带有3列的外部列表,以尝试阅读:组,系统和批准者。

IE 如果用户从“系统”下拉列表中选择“计算机”,则在批准组中的每个人都“我的计算机应用程序”应该得到基于电子邮件在字段和组名中具有字符串“计算机”,那么其他选择也是正确的组。

少于最佳的方式,巨大的if - else陈述我确定是可能的....试图使它变得更加动态,而不是硬编码..

if (Listitem = system
createTask_taskProperties.AssignedTo = "IT Group A"
{
e.Result = true;
}
else
{
if (Listitem = system 2......
.

更新

我能够返回列表,我现在可以根据所谓的项目ID检索项目,如

SPListItem item = list.GetItemById(26);
.

当触发工作流时,我需要找到一个方法来获取列/字段的所有值,以便将该信息传递给变量。一旦完成,我应该能够在CAML查询中调用该变量,以确定需要路由每个项目任务的位置。我以为我从列中获得了GUID,但它只是使用此代码的列表本身的GUID

SPListItem item2 = list.GetItemByUniqueId[new Guid("de417a82-f221-46bd-8003-034ea45de155")];
.

有帮助吗?

解决方案

Your query returns an SPListItem, however you need an SPGroup to retrieve the distribution list email.

To get to the SPGroup object that actually represents the Group itself rather than the name of the Group like you are returning from the List, you need to pull it from an SPWeb (which will be a little trickier since a workflow does not run in the context of a page; I'll leave this to you to figure out).

SPListItem item = list.GetItemById(26); // <-- This is your code here
string strGroupName = item["ColumnWithGroupName"].ToString();

// Get your SPWeb object from which to pull the group here
using (SPWeb webYourWeb = ...)
{
    // (Use SiteGroups or Groups here depending on where you want to pull the group from)
    SPGroup group = webYourWeb.SiteGroups[strGroupName];
    string strGroupEmail = group.DistributionGroupEmail;

    // Send your email
}

That's how you get the email address of a group from the group name (which you got from an SPListItem)

许可以下: CC-BY-SA归因
scroll top