更改“创建者"在 Sharepoint 2007

编程入门 行业动态 更新时间:2024-10-23 04:59:44
本文介绍了更改“创建者"在 Sharepoint 2007的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在共享点列表中创建项目时,我将允许用户选择更改创建者"值.似乎默认隐藏此值并自动填充当前用户.我想在创建或修改项目并预填充当前用户时为用户提供此选项,但也为用户提供更改此字段的选项..

I'd to allow the user to option to change the "created by" value when created an item in a sharepoint list. It seems that it's the default to hide this value and auto-populate the current user. I'd like to give the user this option when creating or modifying an item and pre-populate with the current user, but also give the user the option to change this field..

任何人有任何建议或谁能为我指明正确的方向?

Anyone have any suggestions or whom can point me in the right direction?

非常感谢

推荐答案

创建者"列的内部名称是作者.

编写一个 ItemEventReceiver 并覆盖 ItemUpdated 方法:

Write an ItemEventReceiver and override the ItemUpdated method:

//USER_NAME is user account name that you want to set. public override void ItemUpdated(SPItemEventProperties properties) { SPSecurity.RunWithElevatedPrivileges(delegate { using (SPWeb web = properties.OpenWeb()) { web.AllowUnsafeUpdates = true; // Insert any other updates here SPUser spUser = web.EnsureUser("USER_NAME"); string strUserId = spUser.ID + ";#" + spUser.Name; spListItem["Author"] = strUserId; spListItem.Update(); // if you do not want to change the Modified or Modified By fields, // use spListItem.SystemUpdate() instead } }); }

更新代码;删除了迭代更新.

updated code; removed iterative update.

更多推荐

更改“创建者"在 Sharepoint 2007

本文发布于:2023-11-28 16:54:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643209.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:创建者   quot   Sharepoint

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!