Salesforce API Get SObjects

package com.thysmichels;

import java.io.IOException;

import com.sforce.soap.partner.*;
import com.sforce.ws.*;

public class SalesforceGlobalSearch {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		
		ConnectorConfig sfconfig = new ConnectorConfig();
		//Use your salesforce username = email
	    sfconfig.setUsername("username");
	    //Use your saleforce password with your security token look like: passwordjeIzBAQKkR6FBW8bw5HbVkkkk
	    sfconfig.setPassword("passwordsecuritytoken");
	 
	    PartnerConnection partnercon = null;
	    try {
	    	partnercon = Connector.newConnection(sfconfig);
	        DescribeGlobalResult describeGlobalResult = 
	    	    	partnercon.describeGlobal();
	        if (describeGlobalResult != null)
	        {
	        	Object[] obj = describeGlobalResult.getSobjects();
	        	if (obj != null)
	        		for (int i = 0; i < obj.length; i++)
	        		{
	        			System.out.println("SObjects: " +'\n' + obj[i]);
	        		}
	       }
	        
	      } catch (ConnectionException ce) {
	        ce.printStackTrace();
	      }
	    
	}
}

Output

SObjects: 
[DescribeGlobalSObjectResult  activateable='false'
 createable='true'
 custom='false'
 customSetting='false'
 deletable='true'
 deprecatedAndHidden='false'
 feedEnabled='true'
 keyPrefix='001'
 label='Account'
 labelPlural='Accounts'
 layoutable='true'
 mergeable='true'
 name='Account'
 queryable='true'
 replicateable='true'
 retrieveable='true'
 searchable='true'
 triggerable='true'
 undeletable='true'
 updateable='true'
]
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: