You need to sign in to do that
Don't have an account?
Angela Schloeder
How to have the 'Subject' of the Event clickable and open in a new tab?
I have a VF Page to display all open Events and would like to be able to click the Subject and have the Event open, preferably in a new tab. Right now it's just editable.
<apex:page controller="MeetingBacklogController" tabStyle="Event">
<apex:sectionHeader title="Event" subtitle="Meeting Backlog" />
<apex:form id="form">
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" id="saveButton" value="Save" reRender="form" status="status" />
<apex:commandButton value="Refresh" action="{!refresh}" reRender="form" status="status" />
<apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
<apex:actionStatus startText="Updating..." id="status" />
</apex:pageBlockButtons>
<apex:pageMessages />
<apex:pageMessage severity="info" rendered="{!eventsList.size=0}">
No records found
</apex:pageMessage>
<apex:pageBlockTable rendered="{!eventsList.size>0}" value="{!eventsList}" var="event">
<apex:column headerValue="{!$ObjectType.Event.fields.Set_By__c.Label}" value="{!event.Set_By__c}" />
<apex:column headerValue="{!$ObjectType.Event.fields.Attendee__c.Label}" >
<apex:outputField value="{!event.Attendee__c}" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Event.fields.Meeting_Progression__c.Label}">
<apex:outputField value="{!event.Meeting_Progression__c}" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Event.fields.Client_Invites__c.Label}">
<apex:outputField value="{!event.Client_Invites__c}" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Event.fields.Exec_Invites__c.Label}">
<apex:outputField value="{!event.Exec_Invites__c}" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Event.fields.Meeting_Status__c.Label}">
<apex:outputField value="{!event.Meeting_Status__c}" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Event.fields.StartDateTime.Label}" >
<apex:outputField value=" {!event.StartDateTime}" >
</apex:outputField>
</apex:column>
<apex:column headervalue="{!$ObjectType.Event.fields.Subject.Label}">
<apex:outputField value="{!event.Subject}" label="Subject" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Event.fields.Location.Label}" >
<apex:outputField value="{!event.Location}" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Account.fields.Name.Label}" value="{!event.AccountId}" />
<apex:column headerValue="{!$ObjectType.Contact.fields.Name.Label}" value="{!event.WhoId}" />
<apex:column headerValue="{!$ObjectType.Contact.fields.Title.Label}" value="{!relatedRecords[event.WhoId]['Title']}" />
<apex:column headerValue="{!$ObjectType.Event.fields.Meeting_Location__c.Label}" >
<apex:outputField value=" {!event.Meeting_Location__c}" >
</apex:outputField>
</apex:column>
<apex:inlineEditSupport event="ondblClick"
showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
=====================================================================================================
Controller:
public with sharing class MeetingBacklogController
{
public String events { get; set; }
public List<Event> eventsList{get; set;}
public Map<Id, sObject> relatedRecords{get; set;}
private Map<Id, Event> originalEventsMap;
public MeetingBacklogController()
{
init(true);
}
private void init(Boolean updateUI)
{
Set<String> meetingProgressionValues=new Set<String>();
for(PicklistEntry entry: Event.Meeting_Progression__c.getDescribe().getPicklistValues())
{
if(entry.getValue().startsWithIgnoreCase('M') || entry.getValue().startsWithIgnoreCase('Conf'))
{
meetingProgressionValues.add(entry.getValue());
}
}
originalEventsMap=new Map<Id, Event>([
SELECT Id, Set_By__c, Attendee__c, Meeting_Progression__c, Exec_Invites__c,
Client_Invites__c, Meeting_Status__c,
ActivityDate, StartDateTime, Subject, AccountId, Account.Name, WhoId, Who.Name, Who.Title,
Location, Meeting_Location__c, IsChild
FROM Event
WHERE StartDateTime=NEXT_N_DAYS:90
AND Meeting_Progression__c IN :meetingProgressionValues
AND IsChild=false
]);
relatedRecords=new Map<Id, SObject>();
for(Event record: originalEventsMap.values())
{
relatedRecords.put(record.WhoId, Null);
}
relatedRecords.putAll([SELECT Title FROM Lead WHERE Id IN :relatedRecords.keySet()]);
relatedRecords.putAll([SELECT Title FROM Contact WHERE Id IN :relatedRecords.keySet()]);
relatedRecords.put(Null, new Contact());
eventsList=new List<Event>();
if(updateUI)
{
eventsList=originalEventsMap.values().deepClone(true, true, true);
eventsList.sort();
}
}
public void refresh()
{
init(true);
}
public void save()
{
List<Event> eventsToBeUpdateList=new List<Event>();
for(Integer i=0; i<originalEventsMap.values().size(); i++)
{
for(Integer j=0; j<eventsList.size(); j++)
{
if(originalEventsMap.values()[i].Id==eventsList[j].Id && originalEventsMap.values()[i]!=eventsList[j])
{
eventsToBeUpdateList.add(eventsList[j]);
system.debug('eventsList[j]---->'+eventsList[j]);
break;
}
}
}
Boolean updateUI=true;
try
{
Integer numberOfRecordsUpdated=0;
for(Database.SaveResult result: Database.update(eventsToBeUpdateList, false))
{
updateUI&=result.isSuccess();
if(result.isSuccess())
{
numberOfRecordsUpdated=numberOfRecordsUpdated+1;
}
}
init(updateUI);
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, numberOfRecordsUpdated+' record'+(numberOfRecordsUpdated==1?'':'s')+' saved.'));
}
catch(Exception e)
{
ApexPages.addMessages(e);
}
}
}
<apex:page controller="MeetingBacklogController" tabStyle="Event">
<apex:sectionHeader title="Event" subtitle="Meeting Backlog" />
<apex:form id="form">
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" id="saveButton" value="Save" reRender="form" status="status" />
<apex:commandButton value="Refresh" action="{!refresh}" reRender="form" status="status" />
<apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
<apex:actionStatus startText="Updating..." id="status" />
</apex:pageBlockButtons>
<apex:pageMessages />
<apex:pageMessage severity="info" rendered="{!eventsList.size=0}">
No records found
</apex:pageMessage>
<apex:pageBlockTable rendered="{!eventsList.size>0}" value="{!eventsList}" var="event">
<apex:column headerValue="{!$ObjectType.Event.fields.Set_By__c.Label}" value="{!event.Set_By__c}" />
<apex:column headerValue="{!$ObjectType.Event.fields.Attendee__c.Label}" >
<apex:outputField value="{!event.Attendee__c}" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Event.fields.Meeting_Progression__c.Label}">
<apex:outputField value="{!event.Meeting_Progression__c}" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Event.fields.Client_Invites__c.Label}">
<apex:outputField value="{!event.Client_Invites__c}" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Event.fields.Exec_Invites__c.Label}">
<apex:outputField value="{!event.Exec_Invites__c}" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Event.fields.Meeting_Status__c.Label}">
<apex:outputField value="{!event.Meeting_Status__c}" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Event.fields.StartDateTime.Label}" >
<apex:outputField value=" {!event.StartDateTime}" >
</apex:outputField>
</apex:column>
<apex:column headervalue="{!$ObjectType.Event.fields.Subject.Label}">
<apex:outputField value="{!event.Subject}" label="Subject" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Event.fields.Location.Label}" >
<apex:outputField value="{!event.Location}" >
</apex:outputField>
</apex:column>
<apex:column headerValue="{!$ObjectType.Account.fields.Name.Label}" value="{!event.AccountId}" />
<apex:column headerValue="{!$ObjectType.Contact.fields.Name.Label}" value="{!event.WhoId}" />
<apex:column headerValue="{!$ObjectType.Contact.fields.Title.Label}" value="{!relatedRecords[event.WhoId]['Title']}" />
<apex:column headerValue="{!$ObjectType.Event.fields.Meeting_Location__c.Label}" >
<apex:outputField value=" {!event.Meeting_Location__c}" >
</apex:outputField>
</apex:column>
<apex:inlineEditSupport event="ondblClick"
showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
=====================================================================================================
Controller:
public with sharing class MeetingBacklogController
{
public String events { get; set; }
public List<Event> eventsList{get; set;}
public Map<Id, sObject> relatedRecords{get; set;}
private Map<Id, Event> originalEventsMap;
public MeetingBacklogController()
{
init(true);
}
private void init(Boolean updateUI)
{
Set<String> meetingProgressionValues=new Set<String>();
for(PicklistEntry entry: Event.Meeting_Progression__c.getDescribe().getPicklistValues())
{
if(entry.getValue().startsWithIgnoreCase('M') || entry.getValue().startsWithIgnoreCase('Conf'))
{
meetingProgressionValues.add(entry.getValue());
}
}
originalEventsMap=new Map<Id, Event>([
SELECT Id, Set_By__c, Attendee__c, Meeting_Progression__c, Exec_Invites__c,
Client_Invites__c, Meeting_Status__c,
ActivityDate, StartDateTime, Subject, AccountId, Account.Name, WhoId, Who.Name, Who.Title,
Location, Meeting_Location__c, IsChild
FROM Event
WHERE StartDateTime=NEXT_N_DAYS:90
AND Meeting_Progression__c IN :meetingProgressionValues
AND IsChild=false
]);
relatedRecords=new Map<Id, SObject>();
for(Event record: originalEventsMap.values())
{
relatedRecords.put(record.WhoId, Null);
}
relatedRecords.putAll([SELECT Title FROM Lead WHERE Id IN :relatedRecords.keySet()]);
relatedRecords.putAll([SELECT Title FROM Contact WHERE Id IN :relatedRecords.keySet()]);
relatedRecords.put(Null, new Contact());
eventsList=new List<Event>();
if(updateUI)
{
eventsList=originalEventsMap.values().deepClone(true, true, true);
eventsList.sort();
}
}
public void refresh()
{
init(true);
}
public void save()
{
List<Event> eventsToBeUpdateList=new List<Event>();
for(Integer i=0; i<originalEventsMap.values().size(); i++)
{
for(Integer j=0; j<eventsList.size(); j++)
{
if(originalEventsMap.values()[i].Id==eventsList[j].Id && originalEventsMap.values()[i]!=eventsList[j])
{
eventsToBeUpdateList.add(eventsList[j]);
system.debug('eventsList[j]---->'+eventsList[j]);
break;
}
}
}
Boolean updateUI=true;
try
{
Integer numberOfRecordsUpdated=0;
for(Database.SaveResult result: Database.update(eventsToBeUpdateList, false))
{
updateUI&=result.isSuccess();
if(result.isSuccess())
{
numberOfRecordsUpdated=numberOfRecordsUpdated+1;
}
}
init(updateUI);
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, numberOfRecordsUpdated+' record'+(numberOfRecordsUpdated==1?'':'s')+' saved.'));
}
catch(Exception e)
{
ApexPages.addMessages(e);
}
}
}