This project has moved and is read-only. For the latest updates, please go here.

Clearing a value using SetValue for People and Group fields

Jul 21, 2014 at 8:14 AM
I am using SPUtility to initialize my default EditForm page. For my solution, I am required to clear any document properties when a new document is uploaded. I have just about everything working as needed, except the person / group fields. When I try to clear these values, the following error is thrown:
Unable to get property 'msie' of undefined or null reference.

I have tried each of the following approaches (the first two work great on all of the other data types) and get the same error.
field = SPUtility.GetSPField('Requestor').SetValue();
field = SPUtility.GetSPField('Requestor').SetValue('');
field = SPUtility.GetSPField('Requestor').SetValue(';');

Any advice would be appreciated.

Thanks,
Rick
Jul 22, 2014 at 1:02 AM
Rick,
People fields have given me a lot of trouble so unfortunately I don't have a good way to do what you want. The implementation varies a lot between the different versions of SharePoint so I haven't been able to get anything reliable working... especially in SharePoint 2013.

If you are OK with writing your own jQuery/JavaScript you might be able to get something working. You could reference some of the code I attempted already by looking at SPUtility's source code:
https://github.com/kitmenke/sputility/blob/master/src/sputility.js#L1485

Sorry that isn't much help.
Thanks,
Kit
Jul 23, 2014 at 12:35 AM
Found the following code which clear the value like a champ at https://spservices.codeplex.com/wikipage?title=%24%28%29.SPServices.SPFindPeoplePicker

frankok May 30, 2013 at 2:24 PM
Hi,
To clear a people picker field, do this the old way:
// There's no easy way to find one of these columns; we'll look for the comment with the columnName
var searchText = RegExp("FieldName=\"" + columnName + "\"", "gi");
// Loop through all of the ms-formbody table cells
$("td.ms-formbody").each(function() {
// Check for the right comment
if (searchText.test($(this).html())) {
$(this).find("div[Title='People Picker']").html("");
$(this).find("textarea[title='People Picker']").val("");
$(this).find("img[Title='Check Names']").trigger("click");

return false;
}
});
Good enough for me.
Jul 23, 2014 at 3:18 AM
Great! I'm glad you were able to get it working.