Quantcast
Channel: SharePoint 2013 Activity Event in Newsfeed - SharePoint Stack Exchange
Viewing all articles
Browse latest Browse all 2

SharePoint 2013 Activity Event in Newsfeed

$
0
0

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";
        activityEvent.Commit();

        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?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images