在 Sharepoint Designer 的工作流编辑器中,如何获取工作流发起者用户名?

2024-01-09

在 Sharepoint 设计器的工作流编辑器中,我希望检索工作流发起者的用户名/名称(即谁启动或触发了工作流) - 使用第 3 方产品(例如 Nintex Workflow 2007)(我将在其中使用类似于 {Common:Initiator}) - 但我似乎无法找到任何开箱即用的方法来使用共享点设计器和 MOSS 2007 来执行此操作。

Update

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>

对于通过 google 搜索本文并正在使用 SharePoint 2010 的用户来说,工作流启动器变量现在在 SharePoint Designer 中受 OOTB 支持。

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Sharepoint Designer 的工作流编辑器中,如何获取工作流发起者用户名? 的相关文章

  • 为什么使用SignTool进行代码签名时需要指定时间戳服务器?

    时间戳是可选参数 所以有人可以解释带时间戳的exe文件和不带时间戳的exe文件之间的区别吗 如果我跳过此选项会发生什么 如果您跳过时间戳选项 那么当您的证书过期时 exe 将不再具有有效的证书 如果您使用时间戳服务器 那么 exe 将始终具
  • Python tkinter:在组合框中使用“文本变量”似乎没用

    使用textvariable在 tkinter 中创建组合框时的属性似乎完全没用 有人可以解释一下目的是什么吗 我查看了 Tcl 文档 它说textvariable用于设置默认值 但看起来在 tkinter 中您只需使用 set方法来做到这
  • ASP.NET 入口点?

    刚刚创建了一个空白的 ASP NET Web 应用程序 切入点在哪里 我看到 Default aspx 似乎是调用的默认模板 我猜 Site Master 充当布局文件 Global asax 似乎提供了一些用于事件处理的方法存根 然后是
  • PSQLException:错误:关系“TABLE_NAME”不存在

    我正在尝试在 PostgreSQL 8 4 2 DB 上运行休眠 每当我尝试运行简单的java代码时 例如 List
  • 跳过一行GridBagLayout

    我在 JFrame 上使用 GridBagLayout 我希望能够跳过一两行 但将这些行显示为空白 然后在这些行后面有一个按钮 我在文档中找不到任何方法来执行我所描述的操作 有谁知道我可以执行此操作的任何方法吗 发现它比添加空组件干净得多
  • angular-cli:Karma-Webpack 因“没有此类文件或目录”而失败

    我从Tour of Heroes使用标准 Angular systemjs 现在我正在使用angular client它在开发 生产模式下运行顺利 但我无法测试任何东西ng test 以下内容会被吐出 不仅适用于test ts但也为了pol
  • PostgreSQL 使用 JPA 和 Hibernate 抛出“列的类型为 jsonb,但表达式的类型为 bytea”

    这是我的实体类 映射到表中postgres 9 4 我正在尝试将元数据存储为jsonb在数据库中输入 Entity Table name room categories TypeDef name jsonb typeClass JsonBi
  • 如何使用字符串的值将字符串转换为 wstring?

    我是 C 新手 我有这个问题 我有一个名为 DATA DIR 的字符串 需要将其格式化为 wstring string str DATA DIR std wstring temp L s str Visual Studio 告诉我没有与参数
  • 获取不正确的日期,将时间戳转换为新日期

    我正在尝试将时间戳转换为日期 但得到的日期不正确 我正在开发一个使用 Angular 和 Typescript 的项目 我有这样的时间戳 1451642400 2016年1月1日 和1454320800 2016年2月1日 如果我编码 da
  • 散列 hash_hmac 时,Convert.ToChar(0) 散列结果与 PHP 中的 chr(0) 不同的字符串

    我在 PHP 中有一个字符串 它被转换为字节数组并进行哈希处理 转换为字节数组的字符串如下所示 G 字符 0 便便 我需要 C 中的等效字节数组 这样我才能得到相同的哈希值 编辑 这是完整的问题 生成的哈希值不同 PHP api secre
  • 如何从停止的地方开始播放视频

    我正在使用 VideoView 来播放视频 如果我退出应用程序 在返回应用程序 即在 onResume 中 时 它应该从停止的位置播放视频 要获取当前进度 在 onPause 中检查 long progress mVideoView get
  • Laravel Echo 不监听推送事件

    尝试使用 laravel 和 vuejs 创建一种聊天应用程序 发送消息后 我会从 laravel 触发事件 该事件会使用正确的事件类反映在推送器调试控制台上 但根本不会调用来自 vuejs 的监听回调 created window Ech
  • 尝试访问从资产复制到数据\数据\的数据库中的DatabaseHelper时出现空指针异常

    我有一个数据库助手类 代码如下 这个助手的类任务是将数据库从应用程序附带的资产文件夹复制到我的应用程序的 data data 中 以便我可以使用它 一旦我将数据库放入 data data 我能够 我想添加它并执行 CRUD 操作 并且该数据
  • 如何在 Jetpack Compose 中提供相对大小

    我有一个框布局 我想相对于父框的大小来布局子视图 这可以在 SwiftUI 中使用 Geometry Reader 来实现 如何在 Jetpack Compose 中实现类似的功能 您可以使用BoxWithConstraints代替Box
  • SQL 中 NOT 和 != 运算符有什么区别?

    有什么区别NOT and SQL 中的运算符 我无法理解其中的区别 我猜他们是一样的 NOT negates以下条件 因此它可以与各种运算符一起使用 is the 非标准替代品 https stackoverflow com a 10650
  • 常用姓名别名/昵称数据库

    我参与了一个 SQL NET 项目 该项目将搜索名称列表 我正在寻找一种方法来返回类似名字的人的一些结果 如果搜索 Tom 结果将包括 Thom Thomas 等 这是文件还是 Web 服务并不重要 设计示例 Table Names has
  • 文件构造函数说明

    我无法理解以下文件构造函数 public File String parent String child and public File File parent String child 参数有什么作用parent and child该文件
  • Spring JMS开始根据请求监听jms队列

    Spring提供 JMSListener用于监听来自特定队列的消息的注释 还有一个替代方案实施JmsListenerConfigurer http docs spring io spring docs current spring fram
  • 关闭 IPython Notebook 中的自动保存

    我正在寻找一种方法来关闭 iPython 笔记本中的自动保存 我已经通过 Google Stack Overflow 搜索看到了有关如何打开自动保存的参考资料 但我想要相反的内容 关闭自动保存 如果这是可以永久设置的东西而不是在每个笔记本的
  • “保留供任何使用”是什么意思?

    注意 这是一个c questions tagged c问题 虽然我补充说c questions tagged c 2b 2b如果某些 C 专家可以提供 C 使用与 C 不同的措辞的基本原理或历史原因 在 C 标准库规范中 我们有这个规范文本

随机推荐