1

I have the following Visualforce page and controller:

<apex:page  standardController="sObject" extensions="ExtensionController">
    <div>
         {!o.Id}
    </div>
    <div>
        {!o.Name}
    </div>
</apex:page>

Controller:

public class ExtensionController{

    public SObject  o {get;set;}

    public ExtensionController( ApexPages.StandardController stdController)
    {
        this.o = stdController.getRecord() ;

        ...API CALL...
    }
}

I get the following error

sObject does not exist

Is there any way I can do this? My ultimate goal is to be able to include this page in a few objects' layouts.

4

1 Answer 1

0

When you are extending a page, in the contructor, you need to type cast the stdController.getRecord() value to corresponding object instance. For example (Contact)stdController.getRecord()

For your use case what we can do is to create a generic visualforce component which accept ID of the record. Then get further details using that inside component controller and display in page.

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.