Get group activities using $core_v2_activityMessage.List()

Get group activities using $core_v2_activityMessage.List()

This question has suggested answer(s)

Hi,

How can I fetch the activity message list  for the groups under a specific group. Also accessing user should have membership of such groups to view activity messages.

Thanks.

All Replies
  • Hi,

    You are on the right track by using $core_v2_activityMessage.List(). Under Widget Studio in the API Documentation that extension has an overload method. Here is a sample below that may help:

    	#set($user = $core_v2_user.Accessing)
    	#set($group = $core_v2_group.Current)
    	#set($includeSubGroups = true)
    
    	#set($activityList = $core_v2_activityMessage.List(
    	"%{ GroupId = $group.Id, IncludeSubGroups = $includeSubGroups, UserId = $user.Id}"))
    
    	#foreach($activity in $activityList)
    		<div>$activity.Title</div>
    		<div>$activity.Body</div>
    	#end 
    

    It is strongly suggested to also specify a BeforeDate when including sub-groups to limit the number of messages in the response. You may also want to add paging and other elements.

    Thanks.

  • Hi Rudy,

    Thanks for the response.

    Group that I need to use is not from the current context. I have tried with the parameters as you suggested except group Id  which is from a non-context group. So my call to activity message list method is like below:

    #set($includeSubGroups = true)
    
    $core_v2_activityMessage.List("%{ GroupId = 39, IncludeSubGroups = $includeSubGroups, UserId = $core_v2_user.Accessing.Id}"))
    

    But as a result I am getting activities even for the groups that does not belongs to or not child of the group having id 39. Please suggest.

    Best Regards.

  • My apologies if you remove UserId = $core_v2_user.Accessing.Id from $core_v2_activityMessage.List that should give you only the group and sub-group activities. It will be security trimmed to the accessing user.

    If you want to filter the results to only show the user's activity to the group and sub-groups then you could add the following:

    #foreach($activity in $activityList)
    	#if($activity.Author.Id == $core_v2_user.Accessing.Id)
    		<div>$activity.Title</div>
    		<div>$activity.Body</div>
    	#end
    #end
    
  • Hi,

    Can you please let me know what will be the nesting level of  IncludeSubGroups  parameter. I mean if it has been set to true, will $core_v2_activityMessage.List() consider nested child groups while fetching activity lists.

    Thanks.

  • Yes, nested group activity will be returned as well.