Skip to main content
Hello All,

I have a query regarding Apex please help me out,

I would like to show some details of event in Lead page ((Like meeting Status - Custom Field ) API name - Meeting_Status__c) 

this not the only one i want to show some Checkbox Is that possible to apex Trigger or should I use Apex Class.??

Please provide me a proper Solution or Reference.

I have Already implement this scenario please have a look.

public with sharing class Event_field_on_lead {

public static String ldPrefix = Lead.sObjectType.getDescribe().getKeyPrefix();

public static void updateEvent_field_on_lead(Set<ID> leadIds){

//Query all Leads and task-event child relationships//

List<Lead> Leads = [SELECT Id, LastActivityDate,

(SELECT Id, WhoId, Meeting_Status__c, ActivityDate FROM Events )

FROM Lead WHERE ID IN :leadIds];

List<Lead> updateLeads = new List<Lead>();

for (Lead l : Leads) {

Integer count = l.Events.size();

if (count != 0) {

for (Event e : l.Events){

if (l.LastActivityDate <= e.ActivityDate) {

l.Meeting__c = e.Meeting_Status__c;

}

}

}

updateLeads.add(l);

}

if(updateLeads.size()>0) {

try{

update updateLeads;

}

catch (Exception e) {

}

}

}

}

 
2 answers
  1. Oct 7, 2016, 8:41 AM
    can you tell me what is latestActivity in this code ??

    and Sorry sandhya it is not working, there is some error like 

    Variable does not exist:t.ActivityDate 

     Variable does not exist: latestActivity

     Please assist me ..

    Thanks And Regards 

    Bharat Sharma
0/9000