You need to sign in to do that
Don't have an account?
shobana shobana
how to show the event as seperate related list in pagelayout
Hi Everyone
My scenario is to show the related events record of lead object in pagelayout.
For that i took visualforce page and extension controller.
Actually i am getting output but for delete action will get works when i refresh the page .
Thank you in advance.
My scenario is to show the related events record of lead object in pagelayout.
For that i took visualforce page and extension controller.
Actually i am getting output but for delete action will get works when i refresh the page .
public class forevents { public List<OpenActivity> open{get;set;} public Boolean refreshPage {get; set;} public List<Event> accs { get; set;} public Id leadld{get;set;} public string SelectedEventId { get; set;} public forevents(ApexPages.StandardController controller) { leadld = ApexPages.CurrentPage().getparameters().get('id'); list<lead> c =[SELECT Name, (Select Id,Subject,IsTask, WhoId, ActivityDate, Status, Priority, OwnerId FROM OpenActivities WHERE IsTask=False) FROM Lead WHERE Id = :leadld]; if(c.size() > 0){ open = c[0].OpenActivities; } } public void DeleteEvent() { // if for any reason we are missing the reference if (SelectedEventId == null) { return ; } // find the event record within the collection Event tobeDeleted = null; accs = [Select id, Whoid,description,subject,activitydate from event where Whoid=: leadld ]; for(Event a : accs) if (a.Id == SelectedEventId) { tobeDeleted = a; break; } //if event record found delete it if (tobeDeleted != null) { Delete tobeDeleted; } } public Pagereference refresh() { PageReference secondPage = new PageReference('https://ap1.salesforce.com/{!Leadld}'); secondPage.getParameters().put('id',Leadld); secondPage.setRedirect(true); return secondPage; } } <apex:page standardController="Lead" extensions="forevents" > <apex:form > <apex:pageBlock title="Open Events" > <center><a href="https://ap1.salesforce.com/00U/e?who_id={!leadld}&retURL={!leadld}" target="_top"><button type="button">New Event</button></a> </center> <apex:pageBlockTable value="{!open}" var="each" ><br/> <apex:column headerValue="Action"> <apex:outputlink value="/{!each.id}/e?retURL={!each.WhoId}" target="_top" style="font-weight:bold"> Edit </apex:outputlink> | <a href="javascript:if (window.confirm('Are you sure?')) DeleteEvent('{!each.Id}');" style="font-weight:bold">Del</a> </apex:column> <apex:column headerValue="Subject" value="{!each.Subject}"/> <apex:column headerValue="ActiveDate" value="{!each.ActivityDate}"/> <apex:column headerValue="Status" value="{!each.Status}"/> </apex:pageBlockTable> </apex:pageBlock> <apex:actionFunction action="{!DeleteEvent}" name="DeleteEvent" reRender="form" > <apex:param name="eventid" value="" assignTo="{!SelectedEventId}"/> </apex:actionFunction> </apex:form> </apex:page>Anyone help me out...
Thank you in advance.
You are displaying OpenActivity list in the page> so you have to remove that particular element from the list otherwise you need to query the OpenActivities again.
So it is better to remove from the list.
And also in page while reRender you have specified Id but there is no component with Id
Try below code
Extension:
VF Page
If you are using refersh method for any other purpose keep it otherwise you can remove that method
Regards,
Bhanu Mahesh
All Answers
You are displaying OpenActivity list in the page> so you have to remove that particular element from the list otherwise you need to query the OpenActivities again.
So it is better to remove from the list.
And also in page while reRender you have specified Id but there is no component with Id
Try below code
Extension:
VF Page
If you are using refersh method for any other purpose keep it otherwise you can remove that method
Regards,
Bhanu Mahesh
Thank you for your help.
Its working good.....
Regards,
Bhanu Mahesh
Close the thread if your issue solved