Auto Complete People Picker with current user
- Lucidica - Jamal
- Posts: 7
- Joined: Mon May 13, 2013
Hiya Dmitry
Just a quick question to know if there is a way that you can auto complete the people picker with the current logged in user?
I thought that I had seen it before, but I can't seem to find it via search.
Please can you help?!
Just a quick question to know if there is a way that you can auto complete the people picker with the current logged in user?
I thought that I had seen it before, but I can't seem to find it via search.
Please can you help?!
Hi,
Code: Select all
fd.field('...').value(_spPageContextInfo.userLoginName);
//if the people picker is in server side render mode, also have to do this:
fd.field('...').control()._el().find('a:eq(0)').click()
- Lucidica - Jamal
- Posts: 7
- Joined: Mon May 13, 2013
Hiya Rostislav
Unfortunately it didn't work, when i put the _spPageContextInfo.userLoginName in an alert, i just get "undefined".
Any other suggestions?
Unfortunately it didn't work, when i put the _spPageContextInfo.userLoginName in an alert, i just get "undefined".
Any other suggestions?
Try this
Code: Select all
SP.SOD.executeOrDelayUntilScriptLoaded((function () {
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
ctx.load(web);
var user = web.get_currentUser();
user.retrieve();
ctx.executeQueryAsync(
function () {
fd.field('...').value(user.get_loginName());
//for server-side people picker only
fd.field('...').control()._el().find('a:eq(0)').click();
});
}), "SP.js");
- Lucidica - Jamal
- Posts: 7
- Joined: Mon May 13, 2013
unfortunately, it still doesn't work!
This is on SharePoint Foundation, that doesn't matter does it?
This is on SharePoint Foundation, that doesn't matter does it?
What is implied exactly by "it doesn't work"? Does the following alert the login?
Code: Select all
SP.SOD.executeOrDelayUntilScriptLoaded((function () {
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
ctx.load(web);
var user = web.get_currentUser();
user.retrieve();
ctx.executeQueryAsync(
function () {
alert(user.get_loginName());
});
}), "SP.js");
- Lucidica - Jamal
- Posts: 7
- Joined: Mon May 13, 2013
Hiya Again
Sorry, it seems I made a mistake as now it is working, (the Field name is case sensitive).
Thanks for your help!
Sorry, it seems I made a mistake as now it is working, (the Field name is case sensitive).
Thanks for your help!
-
- Information
-
Who is online
Users browsing this forum: No registered users and 10 guests