cclements
Novice

Access User Profile via JavaScript from Nintex for Office 365 Forms

Community,

Have any of you had any luck accessing the SharePoint User Profile services from JavaScript (JSOM) from a Nintex for Office 365 form?

Some of the problems I run into is a "operation not supported" error when calling the SP.PeopleManager "get_context".

I did manage to dig up a method in the Nintex runtime functions with an interesting comment:

Old client side implementation of user profile lookup.
// This function is preserved to be used later for O365
// May need to create a new lookup object type
NWF.RuntimeFunctions.SPUserProfileLookupClientCall = function (targetUser, profilePropertyNames) {...

Is this for workflow?  Can it be leveraged from a form?

Chris

0 Kudos
Reply
2 Replies
achilles_aditya
Apprentice

Re: Access User Profile via JavaScript from Nintex for Office 365 Forms

Reply
cclements
Novice

Re: Access User Profile via JavaScript from Nintex for Office 365 Forms

Here is code I created to make a call to the user profile service fetching a single specified property:

var deferred = NWF$.Deferred();

if(propertyName == ""){
/* reject the promise and return */
deferred.reject("propertyName was not provided.");
return deferred.promise();
}

if(accountName == ""){
/* reject the promise and return */
deferred.reject("accountName was not provided.");
return deferred.promise();
}

var hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
var appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
var scriptbase = hostweburl + "/_layouts/15/";

var url = appweburl + "/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='" + propertyName + "')?@v='" + encodeURIComponent(accountName) + "'";
var requestHeaders = { "accept": "application/json;odata=verbose" };

var executor = new SP.RequestExecutor(appweburl);

executor.executeAsync({
url: url,
contentType: "application/json;odata=verbose",
method: "GET",
headers: requestHeaders,
success: function (data) {
deferred.resolve(parseResult(data));
},
fail: function (error) {
deferred.reject(error);
}
});

Reply