1

I try to follow a page with JavaScript Object Model. My solution is based on many examples in the web and should work...

var siteActorInfo = new SP.Social.SocialActorInfo();        
siteActorInfo.set_contentUri(siteInfo.Url);
siteActorInfo.set_accountName(accountName);
siteActorInfo.set_actorType(4);

if (siteInfo.Followed)
    followingManager.follow(siteActorInfo);
else
    followingManager.stopFollowing(siteActorInfo);

clientContext.executeQueryAsync(function () {
    if (onSuccess) onSuccess();
}, function (a,error) {
    if (onError) onError(error.get_message());
});

But when I try to follow or unfollow the page, I get this error:

Specified argument was out of the range of valid values. Parameter name: actor.ActorType

The SP.Social.SocialFollowingManager is initialized in another function and generally works.

It was not a problem to retrieve the list of followed sites.

I don't understand, whats the problem here.

Instead of 4 I also tried SP.Social.SocialActorTypes.sites, but this makes, no difference of course, because the value of the property is 4.

1 Answer 1

1

You can isolate the problem by trying to execute below in Console and check if error is still appearing

var context = SP.ClientContext.get_current();
var socialManager = new SP.Social.SocialFollowingManager(context);
var socialSite = new SP.Social.SocialActorInfo();
socialSite.set_contentUri("https://siteurl");
socialSite.set_actorType(SP.Social.SocialActorType.site);
socialManager.follow(socialSite);

context.executeQueryAsync(
    function() { alert('Sites followed!'); },
    function(sender, args) { alert('Error: ' + args.get_message()); });
1
  • With the isolated code it works. At the end, I was successful with my code but I do not know, what ever has been the problem. I'm pretty sure SP.Social.SocialActorType.site had the value 4 this morning. Now it is 2 and using a 4 gives the quoted error, what makes sense. But using the enum I got the same error message. Or I had silly caching problems and worked on old code. Nevermind! Now it works. Thanks :) Commented May 4, 2015 at 12:34

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.