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:
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:
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
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
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