For one of my list I’ve had a very weird issue: one people picker didn’t work properly. If I entered a name and clicked to check it, then it didn’t work. If I saved it and then got back to the form, the value didn’t appear.
This strange behavior is due to a missing SPAN element with _errorLabel as an ID. I have no clue why Sharepoint failed to create this SPAN element… And the error is related to the EntityEditorCallback
function that tries to use the SPAN element, but as it doesn’t exist, it returns NULL and fails the function.
To fix it, I’m checking if the SPAN element exists, and if not I create it.
The below code must be called AFTER the line in your document that says :
document.write('<script type="text/javascript" src="/_layouts/entityeditor.js?rev=vXD0hrzDeHYHbfW8aRSMjA%3D%3D"></' + 'script>');
The code to fix this issue is:
// some People Picker are broken for an unknown reason... // the behavior : we cannot check the name, and the "default" value is not set when editing // the fix : the span with _errorLabel is not created, so we need to create it if (typeof EntityEditorCallback === "function") { var _EntityEditorCallback = EntityEditorCallback; window.EntityEditorCallback = function(result,ctx,preventAutoPostBack) { var errorControl=document.getElementById(getSubControlID(ctx, 'errorLabel')); // if errorControl doesn't exist then we create it if (!errorControl) { var e=document.getElementById(ctx); var spans=e.getElementsByTagName("td"); for (var i=0; i<spans.length; i++) { if (spans[i].getAttribute("colspan") == 3) { spans[i].innerHTML = ''; break; } } } // call the original function _EntityEditorCallback(result,ctx,preventAutoPostBack); } }
Thank you for this post. I just ran into this. The strange thing is the two people pickers that existed in this form before migrating from SP 2010 to SP 2013 still work. Any new people pickers I add do not. Very strange.