+ Start a Discussion

Access SalesForce APIs in custom controller.


Being a newbie to salesforce development this may seem a very basic question.


I made a custom Controller and want to get list of companies or organization that are listed/present in salesforce and display them on visualforce page.

So, is there any API OR sObject (like Account, Contact) in Salesforce to get the company list..


Below is the controller code which I am using currently



public string orgName;


public String getName() {
List<Organization> org = new List<Organization>();
org = [SELECT Id, Name FROM Organization];

for(Integer i=0; i<org.size();i++)
orgName += org[i].Name +',';
return orgName;


but it returns only 'GMail' as output.


I am also not able to find any APIs or API list of salesforce which we can access in apex controllers to get the data.
Please help me out.




Maybe i'm missing something here...


you want a list of all organizations that use salesforce? or a list of companies (partners or something) that you manage within your salesforce instance?


if its the first - its not something accessable from your salesforce org - i doubt if they would publish it at all.

if its the second, than you have to elaborate a little more about your instance.


Hello Noam,


Thanks for the reply. It is the second scenario i.e i want a list of companies within a user's salesforce instance.

i have a salesforce developer account and made a controller & on the visualforce page need to show a list of companies within the user's instance (for now within my instance).


The code which i posted in the initial post in which '[SELECT Id, Name FROM Organization]' soql is used doesn't return the name of all organizations within my instance.


Can you tell that from where we can see the list of organizations in our instance, is it in the Accounts tab or any other tab in salesforce and also is there any API to get such a list or we have to use Organization or any other sObject for this.