2

I'm using this great tool to fill some of the fields in my list. It works great when I do this one by one, but I'm trying to request multiple column values, but I can't get it to work.

var thisUsersValues = $().SPServices.SPGetCurrentUser({
fieldNames: ["ID", "Name", "SIP Address"],
debug: false
});

How can I get specific column value (e.g. "Name") using this way?

1

3 Answers 3

2

You should be able to get the individual values with the following:

var name = thisUsersValues["Name"];

var ID = thisUsersValues["ID"];

var SIPAddress = thisUsersValues["SIP Address"];
0
3

Instead of using fieldNames, just use fieldname.

$().SPServices.SPGetCurrentUser({
  fieldName: "Name",
  debug: false
});

Or using your current function it'd be this I believe:

var thisUsersValues = $().SPServices.SPGetCurrentUser({
fieldNames: ["ID", "Name", "SIP Address"],
debug: false
});
var name = thisUsersValues[1]; 
2
  • thanks for the quick response. I tried just using fieldName:"Name", and it worked, but I'll need to pull the info for several fields (e.g. Email, title, etc, etc.), so I don't want to do them one by one. That's why I used the second version. I also tried before what you proposed "thisUsersValues[1]" and it didn't work, get an 'undefined" message.
    – cubanGuy
    Commented Apr 1, 2014 at 16:39
  • 1
    I'm not in a position to dive into it fully atm. Console log out thisUsersValues and see what it returns, I thought it was an array, he might be returning an object. Commented Apr 1, 2014 at 16:41
3

Since SPServices.SPGetCurrentUser() function returns an associative array where the keys are mapped to fieldNames you could access it as:

var name = thisUserValues.Name;

or

var name = thisUserValues['Name'];
1
  • thanks. Your answer also is correct, but unfortunately i can only mark one response as an answer, and i don't have 15 Reputation to give you at least "point" for helpful answer.
    – cubanGuy
    Commented Apr 1, 2014 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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