I need to add custom notifications to the personal Newsfeed on people's MySites. I found several tutorials and code examples for SharePoint 2010 on the net and tried to do the same with SharePoint 2013. They're all about creating ActivityEvents with the ActivityManager.

Here's the C# code I tried:

        var targetSite = new SPSite("URL to MySite webapp");
        SPServiceContext context = SPServiceContext.GetContext(targetSite);
        var userProfileManager = new UserProfileManager(context);

        var ownerProfile = userProfileManager.GetUserProfile("domain\\user1");
        var publisherProfile = userProfileManager.GetUserProfile("domain\\user2");

        var activityManager = new ActivityManager(ownerProfile, context);

        Entity publisher = new MinimalPerson(publisherProfile).CreateEntity(activityManager);
        Entity owner = new MinimalPerson(ownerProfile).CreateEntity(activityManager);
        ActivityEvent activityEvent = ActivityEvent.CreateActivityEvent(activityManager, 17, owner, publisher);
        activityEvent.Name = "StatusMessage";
        activityEvent.ItemPrivacy = (int)Privacy.Public;
        activityEvent.Owner = owner;
        activityEvent.Publisher = publisher;
        activityEvent.Value = "HELLOOOO";

        ActivityFeedGatherer.BatchWriteActivityEvents(new List<ActivityEvent> { activityEvent }, 0, 1);

The Id 17 in the CreateActivityEvent function is for the StatusMessage activity type, which is layouted like {Publisher} says: {Value} in the ressource files, so I provide the Value property of my ActivityEvent.

The code runs without any exception and in the User Profile Service Application_ProfileDB database I can see the right entries appear in the ActivityEventsConsolidated table. But the activity is not visible in the activity feed, neither on the Owner's one, nor on the Publisher's one, even though these people follow each other. I ran the Activity Feed Job in the CA manually to update the activity feed. Also, I tried to do the same with custom ActivityTypes with own ressource files, same result: The entry in the ActivityEventsConsolidated table (or ActivityEventsPublished if Owner=Publisher) appear, but no entries on the MySite.

Can anyone help?


I found the solution for this problem myself. In Central Administration, Setup MySites, you have to enable the Enable SharePoint 2010 activity migration setting in the Newsfeed section in order to support SP1010 legacy activities in SP2013.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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