You need to sign in to do that
Don't have an account?

How can i dynamically detect what standard controller object using ?
Good day,
Anyone have idea how can i get the standard controller object name from my controller ? meaning if my VF page have standardcontroller = "Account" , then in my controller will able to recognise Account as Standard controller object.
Reason of doing that is i have multiple page which have different standard controller in respective page but they have suppose in same behaviour.
ie :
Mycontroller (ApexPages.StandardController sc){
// how can i know and get dynamically on standard controller object like "Account, Contact..." ?
}
Thanks in advance !
Hi,
first 3 characters of your record id act as unique indentifier for objects
Also getKeyPrefix() method of sObject describe result returns to first 3 character indentifier for any object. You can do some comparision of 1st 3 characters of your record Id andhave some conditional statements in you constructor.
Note: for standard object, unique indentifier would be same but for custom objects it may vary. So you are btter of using getKeyPrefix() method and comparing with your record Ids.
for eg:
Opportunity opp;
Account acc;
Thanks AhmedPot for the suggestion !
at the moment, i trying something like below, believe this can be compare whether it is same SObject
But i got the error like "Invalid field sObjectType" ...do you have idea ?
Strange thing is it work in System log but in IDE not
System.debug('Account.sObjectType=='+Account.sObjectType);
found the issue as it caused by object instance declared the same name :( ...it working fine now