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 

Salesforce MVP | Lightning Champion | 17x Salesforce Certified | Application Architect | 7x Trailhead Ranger | Techforce Services | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *

*