Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Supposedly, SP.Web.ensureUser(user) works according to this MSDN link but I cannot seem to get it to work in my JS code.

While debugging, I can see that SP.Web exists and the user variable is populated with the user that I expect. However I get the following exception:

Object function (b,a){ULSdih:;SP.Web.initializeBase(this,[b,a])} has no method 'ensureUser' 

Watching SP.Web.ensureUser() fail.

share|improve this question
    
Hi! Can you provide some code example how you do invoke this? –  Anatoly Mironov Jan 28 '13 at 16:14

1 Answer 1

up vote 3 down vote accepted

You will have to call the ensureUser method against a valid web object. The following code should work:

var context = SP.ClientContext.get_current();
var theUser = context.get_web().ensureUser("DEV\testowner");
context.load(theUser);

context.executeQueryAsync(function(){

 alert(theUser.get_title());

},
function(sender, args){

  alert(args.get_message());

});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.