我们具有用于多用户日历功能的自定义功能,我们使用vf页面覆盖新的事件标准按钮。我们使用“事件”标准控制器和一个扩展操作。
我们要为所选的多个用户创建事件记录。
请找到我们要求采取行动的以下扩展程序
public class CreateNewTaskController {
public Task currentTask {get; set;}
public Event currentEvent {get; set;}
public CreateNewTaskController(ApexPages.StandardController controller) {
String objType = controller.getRecord().getSObjectType().getDescribe().getName();
if(String.isNotBlank(objType) && objType.equalsIgnoreCase('Task')) {
currentTask = (Task) controller.getRecord();
}
else if(String.isNotBlank(objType) && objType.equalsIgnoreCase('Event')) {
currentEvent = (Event) controller.getRecord();
System.debug('currentevent'+currentEvent);
}
}
public PageReference selectEventRT() {
Id recordTypeId;
String eventSubject = '';
if(currentEvent != null) {
Id myId = currentEvent.WhatId;
if(myId == null) {
myId = currentEvent.WhoId;
}
if(myId != null) {
String sObjName = myId.getSObjectType().getDescribe().getName();
if(sObjName.equalsIgnoreCase('Lead')) {
recordTypeId = Schema.SObjectType.Event.getRecordTypeInfosByName().get('Person Account Event').getRecordTypeId();
}
if(sObjName.equalsIgnoreCase('Account') || sObjName.equalsIgnoreCase('Contact')) {
recordTypeId = Schema.SObjectType.Event.getRecordTypeInfosByName().get('Account Event').getRecordTypeId();
eventSubject = 'Appointment';
}
if(recordTypeId == null) {
recordTypeId = Schema.SObjectType.Event.getRecordTypeInfosByName().get('Other Event').getRecordTypeId();
}
}
else {
recordTypeId = Schema.SObjectType.Event.getRecordTypeInfosByName().get('Other Event').getRecordTypeId();
}
PageReference pgRef = new PageReference('/00U/e');
if(recordTypeId != null) {
pgRef.getParameters().put('RecordType',recordTypeId);
}
Map<String, String> pageParamMap = new Map<String, String>();
pageParamMap = ApexPages.currentPage().getParameters();
for(String paramName : pageParamMap.keySet()) {
if(paramName.equalsIgnoreCase('sfdc.override')) {
pgRef.getParameters().put('nooverride', '1');
}
else {
if(paramName != 'save_new') {
pgRef.getParameters().put(paramName, pageParamMap.get(paramName));
}
}
}
if(String.isNotBlank(eventSubject)) {
pgRef.getParameters().put('title', eventSubject);
pgRef.getParameters().put('tsk5', eventSubject);
}
return pgRef;
}
return null;
}
}