Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在sharepoint designer中';s工作流编辑器如何获取工作流启动器用户名?_Sharepoint_Workflow_Workflow Foundation_Sharepoint Designer_Workflow Activity - Fatal编程技术网

在sharepoint designer中';s工作流编辑器如何获取工作流启动器用户名?

在sharepoint designer中';s工作流编辑器如何获取工作流启动器用户名?,sharepoint,workflow,workflow-foundation,sharepoint-designer,workflow-activity,Sharepoint,Workflow,Workflow Foundation,Sharepoint Designer,Workflow Activity,在Sharepoint designer的工作流编辑器中,我希望检索工作流发起人(即启动工作流或触发工作流的人)的用户名/名称-使用第三方产品(如Nintex workflow 2007,我将使用类似{Common:initiator}的东西)相对容易做到这一点-但使用share point designer和MOSS 2007,我似乎找不到任何开箱即用的方法 更新 看起来OOTB并不支持这个非常明显的特性,所以我最后编写了一个自定义活动(正如其中一个答案所建议的)。我在这里列出了活动代码以供参

在Sharepoint designer的工作流编辑器中,我希望检索工作流发起人(即启动工作流或触发工作流的人)的用户名/名称-使用第三方产品(如Nintex workflow 2007,我将使用类似{Common:initiator}的东西)相对容易做到这一点-但使用share point designer和MOSS 2007,我似乎找不到任何开箱即用的方法

更新

看起来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>

我认为这不可能在SharePoint Designer开箱即用中实现。您可能会编写一个自定义操作来获取发起人,但我认为它根本不会通过SPD工作流界面公开


您最好能找到创建或修改列表中项目的用户,但这无法处理手动运行工作流的情况。

我可以考虑一个简单但不太复杂的解决方案,只使用SPD。仅在工作流步骤中,在辅助列表(可能是存储workflowId和itemId属性以供引用的任务列表)中创建一个测试项,然后在工作流中查找该列表以查看该项的创建者,该值将是当前工作流发起人。

对于那些在本文中使用google并正在使用SharePoint 2010的人,现在SharePoint Designer中支持OOTB工作流发起人变量


数据源将是“工作流上下文”,字段当然是“发起人”,您可以选择将其返回为“显示名称”、“电子邮件”、“登录名”或“用户ID号”

自定义活动解决方案仅在您使用moss时有效,如果您只有wss 3.0,那么您可以在工作流中多做一步,并设置一个包含任何信息的自定义注释字段,这将使最后修改的人员发生更改,并与工作流发起人相同,然后您可以使用ModifiedBy字段做出所需的任何决定。

这是正确答案,尽管根据我的经验,
返回字段作为
选项在用作条件参数时是灰色的。