purtuga / SPWidgets

Sharepoint Custom UI Widgets
74 stars 34 forks source link

Error on people picker #29

Closed green3g closed 10 years ago

green3g commented 10 years ago

I'm getting an error when instantiating a people picker on a sharepoint people picker.

The error occurs on the following:

c.getSearchResults = function(a) {
                    return b.Deferred(function(d) {
                        h.searchPrincipals({searchText: a,maxResults: c.maxSearchResults,principalType: c.type,async: !0,webURL: c.webURL,completefunc: function(f, e) {
                                var h = b(f.responseXML), k = [];
                                -1 < String(c.meKeyword).indexOf(a.toLowerCase()) && k.push({displayName: c.meKeywordLabel,accountId: "<UserID/>",accountName: c.meKeywordLabel,accountType: "User",value: c.meKeywordLabel,label: c.meKeywordLabel});

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined 

It seems like its trying to use the existing value (which is nothing).

It also adds a empty selection to the list of selected people. capture

I'm probably not using it correctly, but could you provide a simple example on how to replace sharepoint's default people picker?

purtuga commented 10 years ago

I have never tried to use it on a OOB sharepoint people picker and do not think it will work.

Can you show me the SPPeoplePicker code? The code you posted is not for the SPWidget I developed.

On Thursday, October 9, 2014, roemhildtg notifications@github.com wrote:

I'm getting an error when instantiating a people picker on a sharepoint people picker.

The error occurs on the following:

c.getSearchResults = function(a) { return b.Deferred(function(d) { h.searchPrincipals({searchText: a,maxResults: c.maxSearchResults,principalType: c.type,async: !0,webURL: c.webURL,completefunc: function(f, e) { var h = b(f.responseXML), k = []; -1 < String(c.meKeyword).indexOf(a.toLowerCase()) && k.push({displayName: c.meKeywordLabel,accountId: "",accountName: c.meKey wordLabel,accountType: "User",value: c.meKeywordLabel,label: c.meKeywordLabel}); Uncaught TypeError: Cannot read property 'toLowerCase' of undefined

It seems like its trying to use the existing value (which is nothing).

It also adds a empty selection to the list of selected people. [image: capture] https://cloud.githubusercontent.com/assets/5471079/4583087/808d2242-4fee-11e4-8d0c-0657c77e040b.PNG

I'm probably not using it correctly, but could you provide a simple example on how to replace sharepoint's default people picker?

— Reply to this email directly or view it on GitHub https://github.com/purtuga/SPWidgets/issues/29.

Paul T.

-- Sent from Mobile

purtuga commented 10 years ago

Correction. The code you posted is (I think) the minified code from my widget. WHat I need to see is how you are calling the widget.

Again: I don't think this is going to work, but let's see what the call looks like.

Paul T.

-- Sent from Mobile

green3g commented 10 years ago

Sorry about that, I was looking at the minified code. the error seems to be occurring here: https://github.com/purtuga/SPWidgets/blob/master/plugin/jquery.SPWidgets.js#L7657

I mistakenly assumed the people picker was meant to replace the ootb one, my bad. I would like to try and implement this though as a replacement, since the ootb doesn't support ie9.

green3g commented 10 years ago

Actually, the call was pretty straighforward. It looked something like:

$('textarea.ms-peoplepicker').pickSPUser();

purtuga commented 10 years ago

Yeah, the widget was designed to be used on custom forms and not the OOB... I have been meaning to see if it could work on the OOB form, but after seeing the code that Marc Anderson has for his utility that picks date pickers and the markup of for them on a SP page, It would be time consuming and I just never got around to it.

If you can figure out how to set the OOB sharepoint picker via javascript, then the approach I would suggest would be to hide it on the OOB page and show the a new picker using this widget... When the User select a person from it, you would use that to set the OOB picker. So basically, you are using one picker to populate another... I have seen some question posted to Stackoverflow recently on that topic (populating people picker with javascript), so maybe you will find an answer.

Here is an example of how to insert the people picker into the page, next to your textarea.ms-peoplepicker:

$('<input type="text" name="pickuser" value=""/>')
    .insertAfter("textarea.ms-peoplepicker")
    .pickSPUser();

BTW: the error you are getting I don't think will happen if you use an input element, rather than a text area... It seems that the searchString is empty, which I have not seen happen with input fields... but I'm going to test that out...

green3g commented 10 years ago

Sounds good. I think we're going to pursue another project I found which is supposed to replace the picker entirely with an HTML5 equivalent: https://peoplepickerplus.codeplex.com/ if you're curious. I appreciate your quick response!

purtuga commented 10 years ago

Thanks Roe. Sorry I have not had the time to look to see if I can get this working with the OOB forms. The project you reference looks like a nice solution and one that once installed and activated, is seen across your site. It needs server admin permissions to install, which is something I don't really get involved with, but if you have that level of access, then you should be good.

Good luck.

Paul T.

-- Sent from Mobile