Skip to main content

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

Similar thread is at https://community.nintex.com/message/4792?et=watches.email.thread#comment-4792 check if it helps


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