How to return a PageReference to create a sObject in salesforce

Using Static:
PageReference ref =  new PageReference(‘/a00/e’);

Using SObject:
public PageReference customObjectPageReference() {
Schema.DescribeSObjectResult R = YourCustomObject__c.SObjectType.getDescribe();
// Add /o to end of URL to view recent
return new PageReference(‘/’ + R.getKeyPrefix() + ‘/e’);

Written by 

3x Salesforce MVP | Platform Champion | 18x Salesforce Certified | MuleSoft Certified | 8x Trailhead Ranger | TechForce Services | Sydney | Australia

Leave a Reply

Your email address will not be published.