我想知道在 SharePoint 列表中,当有人创建新项目时,他们的用户名如何自动填充?分享点列表中是否已经内置了功能?
谢谢!
JQuery) 中的 GetCurrentUser ($().SPServices.SPGetCurrentUser),使用内容编辑器添加 NewForm.aspx。
(function () {
var ctx = {};
ctx.Templates = {};
ctx.Templates.Fields = {
'Applicant': {
'NewForm': renderAssignedTo
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(ctx);
})();
function renderAssignedTo(ctx) {
var currentUser = $().SPServices.SPGetCurrentUser({fieldNames: ["Title", "Name"]});
var currentUserEntry = createUserEntity(currentUser.Name,currentUser.Title);
//Set user default value
ctx.CurrentFieldValue = [];
ctx.CurrentFieldValue.push(currentUserEntry);
return SPClientPeoplePickerCSRTemplate(ctx);
}
function createUserEntity(userLoginName,userDisplayName)
{
return {
Description: userLoginName,
DisplayText: userDisplayName,
EntityGroupName: "",
EntityType: "",
HierarchyIdentifier: null,
IsResolved: true,
Key: userLoginName,
MultipleMatches: [],
ProviderDisplayName: "",
ProviderName: ""
};
}