在SharePoint Designer中的工作流编辑器我怎么在工作流发起人的用户名?(In sha

2019-08-02 01:59发布

在SharePoint Designer中的工作流编辑器我想检索工作流程引发的用户名/名称(即谁踢它关闭或触发工作流) - 这是比较容易使用第三方产品,如Nintex工作流程2007(其中我会用做像{常见:启动器}) - 但我似乎无法找到任何方式开箱做到这一点使用共享点设计器和MOSS 2007。

更新

它看起来并不像这种相当明显的特征就是支持开箱即用的,所以我最后写一个自定义活动(由其中一个答案的建议)。 我在这里列出的活动代码,以供参考,虽然我怀疑有漂浮在那里在博客上,因为它是一个非常平凡的溶液中,该可能是几个例子:

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>

Answer 1:

我不认为这是可能在SharePoint Designer做开箱。 你也许可以写一个自定义操作,以获得鼻祖,但我不认为它是通过SPD工作流接口暴露在所有。

你也许可以做的最好的就是谁创建或修改的列表项的用户,但是这不会处理其中的工作流程是手动运行情况。



Answer 2:

对于那些谷歌在这篇文章和现在使用SharePoint 2010中,工作流发起人变量现在支持在SharePoint Designer开箱即用。

数据源将是“工作流语境”和领域,当然,“始作俑者”,您可以选择将其作为回报的“显示名称”,“电子邮件”,“登录名”或“用户ID号”



Answer 3:

我能想到的这一个只用SPD一个简单但并不是很复杂的解决方案。 就在工作流程步骤创建一个次要列表中的测试项目(可能是一个任务列表,它存储workflowId和的itemId性能做参考回),然后在您的工作流程进行查找名单上,看看谁是该项目的创造者,是值将是当前工作流引发剂。



Answer 4:

这个自定义活动的解决方案只有当你与苔工作的工作,如果你只有WSS 3.0,你可以把一个步骤的更多的工作流程和设置自定义注释字段的任何信息,这使得最后的修改人改变,并成为同如工作流发起人,那么你可以使用ModifiedBy领域做出所需的任何决定。



文章来源: In sharepoint designer's workflow editor how do I get the workflow initiators username?