我有3个自定义视觉力页面。查看记录,编辑哪些编辑以及创建新记录的新视图。编辑和新建有一个保存和新按钮。当我单击“保存”和“新建”时,我需要一个重定向,一个新记录,以及几个要清除的字段,但所有以前的数据都是通过重定向传输的。
我的顶级代码..
public PageReference saveAndNew() {
try {
// Save the current sObject
sController.save();
Schema.DescribeSObjectResult describeResult = sController.getRecord().getSObjectType().getDescribe();
// Create PageReference for creating a new sObject and add any inbound query string parameters.
PageReference pr = new PageReference('/' + describeResult.getKeyPrefix() + '/e?' + queryString);
// Don't redirect with the viewstate of the current record.
pr.setRedirect(true);
eventPackageRevenueBreakdown = new eventPackageRevenueBreakdown__c();
eventPackageRevenueBreakdown.Name = null;
eventpackageRevenueBreakdown.AdminIsIncludedInInclusivePrice__c = false;
return pr;
} catch(Exception e) {
// Don't redirect if something goes wrong. May be a validation or trigger issue on save.
ApexPages.addMessages(e);
return null;
}
}