使用当前登录 sharepoint 的用户名填写文本框

发布于 2024-07-25 16:27:19 字数 244 浏览 7 评论 0原文

我制作了一个自定义列表,它实际上是为缺勤请求工作流程填写的表格。 在发布之前我发现了一个缺陷。 第一个文本框是个人或组文本框,这有助于检索 Active Directory 用户名,但缺陷是我可以输入我想要的任何用户名,例如:

“用户 X 已登录,但如果他输入用户 Y 并点击输入他可以请求用户 Y 缺席”

所以我想要的是隐藏文本框并自动填充当前登录的用户。

我一直在寻找计算文本框的公式,但没有找到任何东西。

I made a custom list, it is actually a form fill out for an absence request workflow. Before publishing it I found a flaw.
The first textbox is a Person or Group textbox, this helps out to retrieve the Active Directory username, but the flaw is that I can type whatever username I want, Example:

"User X is logged on, but if he types User Y and hits enter he can request an absence for User Y"

So what I want is, hide the textbox and fill it automatically with the current logged on user.

I've been looking for formulas for the calculated textboxes but I haven't found anything.

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

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

发布评论

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

评论(4

勿挽旧人 2024-08-01 16:27:19

我不太确定你不想在这里做什么,但如果你有一个想要用当前用户填充的人员选择器,这里是如何做到这一点。 然后,您必须禁用该控件,以便用户无法更改其中的值。

PickerEntity entity = new PickerEntity 
{ 
   Key = SPContext.Current.Web.CurrentUser.LoginName 
};

PeopleEditor.Entities.Add(entity);
PeopleEditor.UpdateEntities(PeopleEditor.Entities);

I´m not exacly sure what you wan´t to do here but if you have a peoplepicker that you want to fill with the current user, here is how to do that. Then you would have to disable the control in order for the user not to be able to change the value in it.

PickerEntity entity = new PickerEntity 
{ 
   Key = SPContext.Current.Web.CurrentUser.LoginName 
};

PeopleEditor.Entities.Add(entity);
PeopleEditor.UpdateEntities(PeopleEditor.Entities);
姜生凉生 2024-08-01 16:27:19

这有帮助吗?

SPUser user = SPContext.Current.Web.CurrentUser;

Does this help?

SPUser user = SPContext.Current.Web.CurrentUser;
心如荒岛 2024-08-01 16:27:19

如果您想要当前登录的用户,只需使用列表中的“创建者”字段即可。 此列会自动填充创建该项目的用户。

If you want the current logged in user, just use the Created By field in the list. This column is automatically populated with the user who created the item.

梦巷 2024-08-01 16:27:19

尝试使用“创建者”并将其粘贴在该字段中的 SharePoint Designer WF。

或者,使用 jQuery 隐藏该列,然后使用字段的默认值 [ME] 来填充该列。 [ME] 用当前登录的用户填写文本框。

编辑:这整个事情可以通过抓住工作流程中的创建者来处理。 您甚至不需要捕获文本框中的值。 SharePoint 知道谁创建了该项目。 这实际上会产生一个不太复杂的形式。

Try SharePoint Designer WF that takes Created By and sticks it in that field.

Or, hide the column using jQuery and just have it populate by using the default value of the field as [ME]. [ME] fills in the textbox with the currently logged in user.

Edit: This whole thing could be dealt with by just grabbing the Created By in the workflow. You don't even need to capture the value in a textbox. SharePoint knows who created the item already. This will actually result in a less complicated form.

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