6

在Sharepoint设计师的工作流编辑器中,我希望检索工作流启动者的用户名/名称(即谁启动它或触发工作流) - 使用第三方产品(例如Nintex Workflow 2007(其中I将使用类似{常见:启动器}) - 但我似乎无法找到任何方式开箱做到这一点使用共享点设计器和MOSS 2007在sharepoint designer的工作流程编辑器中,我如何获得工作流启动器用户名?

更新

它不看起来像这个相当明显的功能是支持OOTB的,所以我最终编写了一个自定义活动(如其中一个答案所示)。我在这里列出的活动代码,以供参考,虽然我怀疑有可能是这个漂浮在那里在博客上,因为它是一个非常平凡解的几个实例:

public partial class LookupInitiatorInfo : Activity 
{ 
    public static DependencyProperty __ActivationPropertiesProperty = 
     DependencyProperty.Register("__ActivationProperties", 
     typeof(Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties), 
     typeof(LookupInitiatorInfo)); 

    public static DependencyProperty __ContextProperty = 
     DependencyProperty.Register("__Context", typeof (WorkflowContext), 
     typeof (LookupInitiatorInfo)); 

    public static DependencyProperty PropertyValueVariableProperty = 
     DependencyProperty.Register("PropertyValueVariable", typeof (string),  
     typeof(LookupInitiatorInfo)); 

    public static DependencyProperty UserPropertyProperty = 
     DependencyProperty.Register("UserProperty", typeof (string), 
     typeof (LookupInitiatorInfo)); 

    public LookupInitiatorInfo() 
    { 
     InitializeComponent(); 
    } 

    [Description("ActivationProperties")] 
    [ValidationOption(ValidationOption.Required)] 
    [Browsable(true)] 
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] 
    public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties __ActivationProperties 
    { 
     get { return ((Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties)(base.GetValue(__ActivationPropertiesProperty))); } 
     set { base.SetValue(__ActivationPropertiesProperty, value); } 
    } 

    [Description("Context")] 
    [ValidationOption(ValidationOption.Required)] 
    [Browsable(true)] 
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] 
    public WorkflowContext __Context 
    { 
     get { return ((WorkflowContext)(base.GetValue(__ContextProperty))); } 
     set { base.SetValue(__ContextProperty, value); } 
    } 

    [Description("UserProperty")] 
    [ValidationOption(ValidationOption.Required)] 
    [Browsable(true)] 
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] 
    public string UserProperty 
    { 
     get { return ((string) (base.GetValue(UserPropertyProperty))); } 
     set { base.SetValue(UserPropertyProperty, value); } 
    } 

    [Description("PropertyValueVariable")] 
    [ValidationOption(ValidationOption.Required)] 
    [Browsable(true)] 
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] 
    public string PropertyValueVariable 
    { 
     get { return ((string) (base.GetValue(PropertyValueVariableProperty))); } 
     set { base.SetValue(PropertyValueVariableProperty, value); } 
    } 

    protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) 
    { 
     // value values for the UserProperty (in most cases you 
     // would use LoginName or Name) 

     //Sid 
     //ID 
     //LoginName 
     //Name 
     //IsDomainGroup 
     //Email 
     //RawSid 
     //Notes 

     try 
     { 
      string err = string.Empty; 

      if (__ActivationProperties == null) 
      { 
       err = "__ActivationProperties was null"; 
      } 
      else 
      { 
       SPUser user = __ActivationProperties.OriginatorUser; 

       if (user != null && UserProperty != null) 
       { 
        PropertyInfo property = typeof (SPUser).GetProperty(UserProperty); 
        if (property != null) 
        { 
         object value = property.GetValue(user, null); 
         PropertyValueVariable = (value != null) ? value.ToString() : ""; 
        } 
        else 
        { 
         err = string.Format("no property found with the name \"{0}\"", UserProperty); 
        } 
       } 
       else 
       { 
        err = "__ActivationProperties.OriginatorUser was null"; 
       } 
      } 
      if (!string.IsNullOrEmpty(err)) 
       Common.LogExceptionToWorkflowHistory(new ArgumentOutOfRangeException(err), executionContext, 
                WorkflowInstanceId); 
     } 
     catch (Exception e) 
     { 
      Common.LogExceptionToWorkflowHistory(e, executionContext, WorkflowInstanceId); 
     } 

     return ActivityExecutionStatus.Closed; 
    } 
} 

然后用以下.action接线起来xml文件:

<?xml version="1.0" encoding="utf-8"?> 
<WorkflowInfo Language="en-us"> 
<Actions> 
    <Action Name="Lookup initiator user property" 
ClassName="XXX.ActivityLibrary.LookupInitiatorInfo" 
Assembly="XXX.ActivityLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XXX" 
AppliesTo="all" 
Category="WormaldWorkflow Custom Actions"> 
     <RuleDesigner Sentence="Lookup initating users property named %1 and store in %2"> 
      <FieldBind Field="UserProperty" DesignerType="TextArea" Id="1" Text="LoginName" />    
      <FieldBind Field="PropertyValueVariable" DesignerType="ParameterNames" Text="variable" Id="2"/> 
     </RuleDesigner> 
     <Parameters> 
      <Parameter Name="__Context" Type="Microsoft.Sharepoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions" Direction="In"/> 
      <Parameter Name="__ActivationProperties" Type="Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties, Microsoft.SharePoint" Direction="In"/> 
      <Parameter Name="UserProperty" Type="System.String, mscorlib" Direction="In" /> 
      <Parameter Name="PropertyValueVariable" Type="System.String, mscorlib" Direction="Out" /> 
     </Parameters> 
    </Action> 
</Actions> 
</WorkflowInfo> 

回答

2

我认为这不可能在SharePoint Designer开箱即用。您可能可以编写一个自定义操作来获取发件人,但我不认为它完全通过SPD工作流界面公开。

您可以做的最好的方式是获取在列表中创建或修改项目的用户,但这不会处理手动运行工作流程的情况。

+0

现在在SharePoint 2010中支持OOTB - 请参阅下面的答案 – Bkwdesign 2013-09-19 03:24:38

1

我可以通过使用SPD来思考一个简单但不是非常复杂的解决方案。在工作流程步骤中,在辅助列表中创建一个测试项目(可能是存储refId的workflowId和itemId属性的任务列表),然后在您的工作流程中查找该列表中的项目,查看该项目的创建者价值将成为当前的工作流发起人。

4

对于那些在本文中使用SharePoint 2010的人来说,现在SharePoint Designer中支持OOTB工作流启动器变量。

数据源将是“工作流上下文”,该字段当然是“启动器”,您可以选择将其作为“显示名称”,“电子邮件”,“登录名”或“用户ID数字“

0

定制活动解决方案仅适用于使用苔藓的情况,如果您只有wss 3.0,则可以在工作流程中再添加一步,并使用任何信息设置定制注释字段,这会使最后修改的人员要更改并变得与工作流启动器相同,则可以使用ModifiedBy字段来做出您需要的任何决定。

相关问题