Domanda

I am trying to get the current user's list of "My Links" using SPServices & jQuery

I am new to SPServices and I found this page about how to get values from the user's profile and specifically the supported operation GetUserLinks, however, I am not sure how to format this request.

Here is my lame attempt:

var UserName = $().SPServices.SPGetCurrentUser({
   fieldName: "Name",
   debug: false
});
var UserLinks = $().SPServices.UserProfileService.GetUserLinks(UserName)

I appreciate any help constructing this!

È stato utile?

Soluzione

The correct syntax is :

$().SPServices({
  operation: "GetUserLinks",
  accountName:"username",
  completefunc: function (xData, Status) {
    console.log(xData)
  }
});

Your syntax for the SPGetCurrentUser is correct but that doesn't on my Sharepoint... I see, at least, two other options to find the current user :

  1. With SharepointPlus (a JavaScript API) :

    $SP().whoami({url:"http://my.si.te/subdir/"}, function(people) {
      console.log(people["AccountName"]);
    });
    
  2. Or you can change your masterpage to always have the details regarding the current user into your code. Have a look at this English blog post or this French blog post. Then it's easy to get the username from the HTML directly.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top