Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a visualforce page, and a controller class. the object name is Calculator__c. I have a method which sends an email out with the data. and the send email method is called after save() method. on one line, I have

mail.setSubject('Calculator -- Manager Approval Request ' + Calculator__c.Id);

I set the email send to myself, and when I got it, the email Subject only says: "Calculator -- Manager Approval Request Id", the actual Id number was not sent. can someone help, thanks so much.

share|improve this question
Can you post the controller code and visualforce? My guess is you're simply instantiating a new Calculator__c object and never retrieving it. – James Loghry Jan 27 '14 at 20:41
up vote 5 down vote accepted

Calculator__c.Id is a field reference (Schema.Calculator__c.Id). You need to reference an instance of the record (say, from your ApexPages.StandardController controller parameter), such as controller.getRecord().Id or controller.getId().

Edit: I should note that if you're using an extension, you want to save the StandardController that the constructor provides. If you're using a controller, you have to create an instance of the record yourself as a member variable, such as:

public class X {
    public Calculator__c calc { get; set; }
    public X() {
        calc = new Calculator__c(); // Or do a query, etc.

At which point, you'd want to refer to calc.Id (assuming you've inserted or queried first).

share|improve this answer
works. thank you so much – user3088377 Jan 27 '14 at 20:58

You need to change it to reference the actual record's Id. Calculator__c.Id will retrieve information about that field on the object model instead of the value of the record.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.