For some reason I'm unable to pass Task Id and subject to another controller from this extension controller. Any help?

public with sharing class MyExtensionController {
        private final Task t;

        public MyExtensionController (ApexPages.StandardController sc) {
            this.t = (Task)sc.getRecord();        

        public static string DoSomething() { 
           return 't.Id';

Error: Compile Error: Variable does not exist: t.Id

Please note I want to avoid passing task as a variable to my method "DoSomething". In other words I want to avoid this:

public static string DoSomething(Task t) { 
           return 't.Id';

You are making the opposite mistake as this other question posted at almost the exact same time: Method does not exist or incorrect signature...why?

In this case, you have marked the method as static when it should be an instance method. You can only access instance properties from instance methods. Simply remove the static keyword from your method definition.


Your method is static, so it would not access class level variables as parameters.

  • This could be post a comment – Reshma Feb 17 '17 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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