I needed to set a default value for the Assigned To field for a task. I wanted it to default to the current user. The script provided at Andy Bonner’s Blog gives a great sample of this. His script sets the value for the Submitted By field. If you want it to work for the Assigned To field, change this line:
fillPeoplePickerWithCurrentUser(’Submitted_x0020_By’);
to:
fillPeoplePickerWithCurrentUser(’AssignedTo’);
To add the script, you will need to add a Content Editor Web Part to the New Form page. To do this, add the following to the end of the new form url:
?PageView=Shared&ToolPaneView=2
You will then be able to add web parts to the page. Add the Content Editor Web Part to the page, then Edit Source and add the script. Set the web part to be hidden, and you are done.
I found this great POST by the SharePoint Designer team for “Using Javascript to Manipulate a List Form Field”. Unfortunately it didn’t work very well for People Picker fields which is exactly what I needed to do today.
After some trial and error, and a bit of head scratching I finally came up with the follow which I thought I’d share, since when I was searching for a solution I found a lot of people in a similar situation with no solution posted.
How to set SharePoint People Picker default value to current user through javascript
Random Posts
Loading…