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

Dynamic ObjectName
Hi All,
I create one button on Contact(example) it send to Dynamic SOQL vfpage, but i am creating this button on every object. how to send object name dynamically through url or any other stuff.
in controller i am using dynamic SOQL.
Example:
window.location ='/apex/DynamicSOQL?type={!$SObject}';
Regards,
Ravi.
As you said that you have created separate button for each object, then the code posted should work fine.
For ex: suppose you have created separate button for Account , Opportunity etc.
In the javacript code for the button on Account you should have the URL as,
window.location ='/apex/DynamicSOQL?type={!$SObject.Account}';
For the button on Opportunity, the URL in javascript should be
window.location ='/apex/DynamicSOQL?type={!$SObject.Opportunity}';
Let me know if you still have queries.
All Answers
Hi
Try this
'/apex/DynamicSOQL?type=?'+{!$ObjectType.book__c}
Hi,
In your custom button code, select the object you have created the button into.
window.location ='/apex/DynamicSOQL?type={!$SObject.<<CurrentObject>>}';
This statement ({!$SObject.<<CurrentObject>>}) will return 3 characters which is the prefix of object.
In the Apex class,
Get the qyery parameter, then
Hi Imaran,
i want to get CurrentObject is dynamically.
window.location ='/apex/DynamicSOQL?type={!$SObject.<<CurrentObject>>}';
As you said that you have created separate button for each object, then the code posted should work fine.
For ex: suppose you have created separate button for Account , Opportunity etc.
In the javacript code for the button on Account you should have the URL as,
window.location ='/apex/DynamicSOQL?type={!$SObject.Account}';
For the button on Opportunity, the URL in javascript should be
window.location ='/apex/DynamicSOQL?type={!$SObject.Opportunity}';
Let me know if you still have queries.
Hi Imran,
But user create button. in simply paste the code without any changes any possibility.
like CurrentObjectName this is either account , contact, some other object. where i am placing the button that object name i want.
window.location ='/apex/DynamicSOQL?type={!$SObject.CurrentObjectName}';
and in button javascript following error is coming.
Field $SObject.Account does not exist. Check spelling.
Hi,
Replace {!$SObject.CurrentObjectName} with {!$ObjectType.Account}
Sorry till now i thought you are referring to {!$ObjectType.CurrentObjectName}
In the URL it should be
window.location ='/apex/DynamicSOQL?type={!$ObjectType.CurrentObjectName}';
i want type is dynamically.
i want this dynamic CurrentObjectName where i place button that object name
window.location ='/apex/DynamicSOQL?type={!$ObjectType.CurrentObjectName}';
Chandra,
From Javascript, the prefix of the object will be determined and will be sent to Apex controller.
To find the object name, you have to use the apex code which i posted in the thread.
my requirement is user create a custom button in any object(account,contact,Project__c.....etc)
just copy and paste the JavaScript code on button. but he dont know the object api name. I want universal(global) code working in every object without any replacing existing script code . any possibility to do this.
any possibility to send CurrentObjectName dynamically without hard coding($ObjectType.Account.....).
window.location ='/apex/DynamicSOQL?type={!$ObjectType.CurrentObjectName}';