var tags = document.getElementsByTagName('DIV');
var count = 0;
for(var i=0;i<tags.length;i++)
{
if(tags[i].title == 'People Picker')
{
count = count +1;
if(count == 2)
{
SetTheCurrentUser1(tags[i].id);
}
}
}
function SetTheCurrentUser1(ctrlPeoplePicker)
{
var currentUser = "";
currentUser = $().SPServices.SPGetCurrentUser({
fieldName: "Name"
});
// alert(currentUser);
if(currentUser != "")
{
svSetPeoplePickerValue(ctrlPeoplePicker,currentUser);
}
}
function svSetPeoplePickerValue(strControlId, strValue)
{
var ctlUpLevel = document.getElementById(strControlId);
// Get the portion of the ID preceeding '_upLevelDiv'
// all controls' ids for the people picker start with this
var subs = ctlUpLevel.id.substring(0, ctlUpLevel.id.indexOf("_upLevelDiv"));
// Magically set the value of the People Picker (and associated fields)
var ctlDownLevel = document.getElementById(getSubControlID(subs, g_EntityEditorDownLevelId));
ctlDownLevel.value = strValue;
SetInnerText(ctlUpLevel, strValue);
copyUplevelToHidden(subs);
}
// The functions getSubControlID, SetInnerText, copyUplevelToHidden and
// the variable g_EntityEditorDownLevelId are provided by SharePoint.
No comments:
Post a Comment