Skip to main content

Hi all!

 

For some time I am struggling with using the "PeoplePickerAPI" in Nintex Forms for Office 365. According to the documentation, it should be present under the "NF" object here: NF.PeoplePickerApi (People Picker Extensions - Nintex Forms). But as I expand the NF object in a browser, I see no PeoplePickerApi constructor:

209036_pastedImage_12.png

So, after discussion with Rebecca Gordon, I decided to give a try to the code she provided, that should add the missing constructor:

NF.PeoplePickerApi = (function ($) {

    var getData = function (ins) {
        ins.d = ins.d || ins.$elem.data("uiItempicker");
        return ins.d;
    };

    var ctor = function (elem) {
        this.$elem = $(elem);
    };

    ctor.prototype = {
        added: function (func) {
            var a = getData(this).options.itemAdded;
            getData(this).options.itemAdded = function () {
                a();
                func();
            };
        },
        removed: function (func) {
            var r = getData(this).options.itemRemoved;
            getData(this).options.itemRemoved = function () {
                r();
                func();
            };
        },
        search: function (term) {
            var config = this.$elem.data();
            return $.getJSON(config.url + "/_vti_bin/NintexFormsServices/NfRestService.svc/AutocompleteValue/PeoplePicker",
                { term: term, types: config.selectionset, group: config.sharepointgroup, });
        },
        add: function (value) {
            getData(this)._addItem(value);
        },
        remove: function (valueOrPredicate) {
            var self = this; var func = $.isFunction(valueOrPredicate) ? valueOrPredicate : function () {
                return this == valueOrPredicate;
            };
            var items = this.$elem.parent().find('.ip-item').filter(function (index) {
                return func.call($(this).data('val'));
            });
            items.each(function () {
                getData(self)._removeItem($(this));
            });
        },
        clear: function () {
            var self = this; self.$elem.parent().find('.ip-item').each(function () {
                getData(self)._removeItem($(this))
            });
        }
    };

    return ctor;
})(NWF$);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

All functions seems to be working, but not the "SEARCH". Search refers to the "var config = this.$elem.data();", which in case of Office 365 is contains the following properties:

209037_pastedImage_14.png

 

Unfortunately there is no: "config.url" property within. 

 

I gave a try and started browsing the Nintex Forms scripts, searching for another, that is using the "/_vti_bin/NintexFormsServices/NfRestService.svc" web service, so maybe I could discover what path should be there. The only one I found was in the https://neu-des-fol.nintexo365.net/Forms/Scripts/RuntimeFunctions.js?ver=101.1.0.0 used by the "NWF.ClientRequests.UserProfileLookup" function, to call: NWF.Utilities.AjaxPost("/_vti_bin/NintexFormsServices/NfRestService.svc/GetUserProfilePropertiesForUser", requestData, cbSuccess, cbError);

 

But then I got lost, because the "AjaxPost" function from the https://neu-des-fol.nintexo365.net/Ext/Filler.min.js?v=Z5IbnsS0-jWgs_GrTpXSiJTDtY5bBZI6QPOh2C2kmjw1 file did not stopped on the set breakpoint, so I guess the function used by the RuntimeFunctions.js is somewhere else sad.png

 

Then I tried to simply ask the webservice for the WSDL, but in return I received the information: "The endpoint /formsapp/_vti_bin/nintexformsservices/nfrestservice.svc is not accessible in the context of a SharePoint App." when I was trying to use the "appweburl" (decodeURIComponent(getQueryStringParameter('SPAppWebUrl')) as the replacement for the "config.url", what tells me, that this is the right URL, but for some reason cannot be called directly sad.png

 

So I got lost again and stuck this time. I have no idea how to make that "Search" function to work. Can anyone help me here?

 

Regards,

Tomasz

 

P.S.

I also tried to follow Kok Koon Gan‌ post (JavaScript to get List Items and User Profiles from Nintex Forms for Office 365) regarding calling the SP REST APIs from Nintex Forms for Office 365 having in mind the cross-domain restrictions, but as calls to lists are working, calls to the UserProfile endpoints fails continuously, but that is a separate investigation wink.png

Hi Tomasz Poszytek‌,

What is the outcome that you are trying to achieve here ?

Even i had a similar experience using the PeoplePickerAPI , it does not seem to work in Office 365.

In my case i wanted to retrieve the user profile properties (by default Nintex Forms App for office 365 does not the required permission to access the user profile service).

If you are looking for something similar refer the following post.

Retrieve User Profile Details on Nintex Form for Office 365 3Step – By – Step] 


Hi

I saw your post, thanks  Still I just want to try to check all built-in possibilities before going into that solution, as normally it requires a SharePoint admin permissions (or even tenant?) to grant that trust, that is not always directly feasible, requires more time to process, at least for some of the customers I work with.

Anyway - what I want to achieve is this simple - search for the specific user and then add him to the other people picker field. And of course - I can do that using your approach - get user data using AJAX calls to REST, then build the json string to pass to the "Add" method, but as I wrote - want to check all OOB options first.

Regards,

Tomasz


Good Luck !!

Definitely , will keep you posted if i get the PeoplePickerApi to work in Office365.


Anybody? Nintexers, how do you handle custom user profiles lookup in Nintex for Office 365? What's your tried and working approaches?

Regards,

Tomasz


Reply