function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ashu sharma 38Ashu sharma 38 

How to display activity for related object in object?


I have a requirement,have to show Custom object activity in contact related list.::
Contact and Custom__c,In this custom object I have to show activity of contacts.

Ashima nidhiAshima nidhi
Please see the below doc to do the same , However there should be a relationship between the new object and contact to do the same.

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.
Hi Ashu Sharma,

I have gone through your problem. 

I think you have to create an Aura Component. and show all related contact activities.

The below URL can help to create an Aura Component. 

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora
Ashu sharma 38Ashu sharma 38
Hi Sachin,

Thanks for your reply,
As per my req I am trying,but not getting appropriate on it.Kindly suggesting on this follow:

 public static list<Task> getContactTask(string contactId){
        system.debug('contactId ' +contactId );
        list<task> contactTask=new list<task>();
        list<contact> consList=[select id,name,(select id from applications__r) from contact where id=:contactId];
        list<Task> tsk=[select id,whoId from task where whoId=:consList[0].id];
        system.debug('Task' +tsk);
        return tsk;

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes"
                access="global" controller="ContactActivityHistory">
    <aura:attribute name="recordId" type="Id"/>
    <aura:attribute name="newTask" type="Task" default="{'sobjectType':'Task'}"/>
    <aura:attribute name="tasks" type="Task[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:iteration items="{!v.tasks}" var="item">
        {!item.Subject}, {!item.ActivityDate}<br/>

    doInit : function(component, event, helper)
        console.log('Test activity');
        var action = component.get("c.getContactTask");
        console.log('Test Activity @@@@');
        // var action=component.get('v.recordId');
            ContactId : component.get('v.recordId')
        console.log('Test my contact record activity ' +component.get('v.recordId'));
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === "SUCCESS"){
               // var records = response.getReturnValue();
               // console.log('Server-> ' + JSON.stringify(records));
                alert("From server: " + response.getReturnValue());
                var newItems=[];
                for (var i=0; i< records.length; i++)
                    var record = records[i];
                    console.log('record-> ' + JSON.stringify(record));
                    //   var Item = {title: record.Name, id: record.Id, status: "Unassigned"};
                    //  console.log('Item-> ' + JSON.stringify(Item));
                    console.log('newItems-> ' + JSON.stringify(newItems));
                component.set("v.tasks", newItems);
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 

As not working for me...