Sharepoint OnWorkflowItemChanged 在属性列表之前/之后

发布于 2024-07-19 21:26:25 字数 380 浏览 4 评论 0原文

我想在 WSS 3.0 状态机工作流中使用 OnWorkflowItemChanged 事件来检查对启动工作流的列表项所做的更改。 此事件的属性包括更改之前和之后的属性,我可以毫无问题地绑定到之后的属性,并获取使用列表项的更改值设置的属性。 然而,属性之前的绑定始终为空,经过一些研究,我发现了这个 http: //msdn.microsoft.com/en-us/library/aa979520.aspx 表示之前的属性仅适用于文档库,不适用于列表。

我想知道的是,是否有解决此缺失功能的方法,或者获得此功能的最佳方法是什么?

I would like to use the OnWorkflowItemChanged event in a WSS 3.0 State machine workflow to check for changes made to the list item that kicked off a workflow. The properties of this event include before and after change properties and I can bind to the after properties with no problem and get a property set with the changed values of the list item. However the bound before properties are always empty and after some research I have found this http://msdn.microsoft.com/en-us/library/aa979520.aspx which says before properties are only available on document libraries and not lists.

What I would like to know is if there is a workaround to this missing functionality or what would be the best approach to get this functionality?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

才能让你更想念 2024-07-26 21:26:25

我克服这个问题的方法是使用该项目的先前版本。 当然,必须在列表上启用版本控制。

// get an object referencing the item in the list
Guid listGuid = new Guid(listId);
SPList myList = web.Lists[listGuid];
SPListItem myItem = myList.GetItemById(itemId);

// make sure there is at least one previous version to compare
// 0 -> current version
// 1 -> previous version
// 2 -> older version
// ...
if (myItem.Versions.Count > 1)
{
    SPListItemVersion newItem = myItem.Versions[0];
    SPListItemVersion oldItem = myItem.Versions[1];
}

The way that I overcame this problem was by using the item's previous version. Of course, versioning must be enabled on the list.

// get an object referencing the item in the list
Guid listGuid = new Guid(listId);
SPList myList = web.Lists[listGuid];
SPListItem myItem = myList.GetItemById(itemId);

// make sure there is at least one previous version to compare
// 0 -> current version
// 1 -> previous version
// 2 -> older version
// ...
if (myItem.Versions.Count > 1)
{
    SPListItemVersion newItem = myItem.Versions[0];
    SPListItemVersion oldItem = myItem.Versions[1];
}
私藏温柔 2024-07-26 21:26:25

我目前使用了以下解决方法,并希望得到一些关于其他人想法的反馈。 我个人不喜欢它,因为我认为应该有一种方法来访问框架提供的这些信息。

我在等待项目更改的状态初始化中创建了一个执行自定义代码活动。 以下代码将属性保存到工作流中的一个字段,以便在更新后进行访问

SPListItem item = workflowProperties.Item;
item.Update();

beforeApplicationChangedProperties = new Hashtable();
foreach (SPField field in item.ContentType.Fields)
{
    if (!beforeApplicationChangedProperties.ContainsKey(field.Title))
    {
        beforeApplicationChangedProperties.Add(field.Title, item[field.Id]);
    }
}

其他人怎么看?

I have currently used the following workaround and would like some feedback as to what others think. Personally I don't like it as I think there should be a way of accessing this information provided by the framework.

I have created an execute custom code activity in the state initialization of the state which waits for the item to be changed. The following code saves the properties to a field within the workflow for access after the update has occured

SPListItem item = workflowProperties.Item;
item.Update();

beforeApplicationChangedProperties = new Hashtable();
foreach (SPField field in item.ContentType.Fields)
{
    if (!beforeApplicationChangedProperties.ContainsKey(field.Title))
    {
        beforeApplicationChangedProperties.Add(field.Title, item[field.Id]);
    }
}

What do others think?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文