function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
LithiumsLithiums 

Overwritting New

I have overwritten the custom object 'New' button, I would like to access the id of the record when they click the 'New' button. Is it possible to get the Id of the record before it is committed to the DB(sounds stupid..but i thought I will still go ahead and ask)

This is the contructor

 

private Sales__c salesesource;

public salesResourceController(ApexPages.StandardController controller) {
        salesesource = (Sales__c)controller.getRecord();
        System.debug('Called salesResourceController' +salesesource );
    }

Best Answer chosen by Admin (Salesforce Developers) 
Suresh RaghuramSuresh Raghuram

you can get it by saving temporly and then create savepoint and  rolling back  in the mean while of this process u can get the record id by using getCurrentId()

All Answers

vriavmvriavm

No this is not possible because the record is not saved and there is no logical ID created by SFDC at this point of time...

 

Suresh RaghuramSuresh Raghuram

you can get it by saving temporly and then create savepoint and  rolling back  in the mean while of this process u can get the record id by using getCurrentId()

This was selected as the best answer