Hiding home page components in Salesforce

Setup --> Customize --> Home --> Home Page Layout.


Click Edit button.


Uncheck the checkbox to hide it in Home page.


Cheers!!!

How to display checkbox options in vertical direction in salesforce

To display checkbox options in vertical direction, layout property is used.

Example:

<apex:selectCheckboxes value="{!relObjs}" layout="pageDirection">
    <apex:selectOptions value="{!relObj}"/>
</apex:selectCheckboxes>


Cheers!!!

Salesforce to Salesforce Connection

Salesforce to Salesforce connection can be used for data sharing. If an organization is too big and they are using two Salesforce.com organizations to avoid governor limits in Salesforce.com, to share data among the two Salesforce.com organizations without any charge they can go for Salesforce to Salesforce Connection.

Salesforce to Salesforce connection avoids unnecessary API Calls and web service for sharing data among two different Salesforce.com organizations.

Step 1: Create a contact
Create a contact of the Salesforce account.



Step 2: Enabling Salesforce to Salesforce connection
To enable the Salesforce to Salesforce connection, go to Setup --> Customize --> Salesforce to Salesforce.
Click Settings, Click Edit, Check Enable checkbox and Click "Save" button.




Note: Do the step 2 for both the Salesforce logins.

Step 3: Add Connection Tab
Add connection tab to the application.
Do the step2 for both the Salesforce logins.




Note: Do the step 3 for both the Salesforce logins.

Step 4: Creating connection
1.   Go to the connection tab and click new button.


2.   Add Contact, Account and Connection Owner to the new connection.


3.   Click Save & Invite button.

Step 5: Accept Invitation
  1. Check the e-Mail to accept the connection. 
  2. Click the link in the Invitation e-Mail.

  1. The link will direct to login url.
  2. Give your login credential.
  3. Click Login button.


  1. Accept the invitaion




Step 6: Publish Objects

  1. Click Publish/Unpublish button.


  1. Select the Objects to publish.
  2. Edit the published objects fields.



Step 7: Subscribing Objects

  1. Click Subscribe/Unsubscribe button. 


  1. Map the fields.
  2. Click Save button.

Step 8: Adding External Sharing related list
Add the External Sharing related list to both the logins.


Step 9: Sharing Data
  1. Create an account.
  2. Click Forward this Account.

  1. Select the connection.





  1. Check Notification e-Mail.
  2. Go to Accounts tab in another Salesforce login.
  3. Scroll down and Click Go button in Accounts from Connections.


  1. Click Accept link.


  1. Click Save button.

Searching data in Salesforce using Web Service API

To search data in Salesforce using external application, search () method is used.

search ()

Execute a text search in your organization’s data. Use search () to search for records based on a search string. The search () call supports searching custom objects. For an extensive discussion about the syntax and rules used for text searches, see Salesforce Object Search Language (SOSL). Certain objects cannot be searched via the API, such as Attachment objects. To search an object via the search () call, the object must be configured as searchable (isSearchable is true). To determine whether an object can be searched, your client application can invoke the describeSObjects() call on the object and inspect its searchable property.

Syntax

SearchResult = connection.search(String searchString);

where connection is an object of EnterpriseConnection.



Cheers!!!

Iterator in Web Service API using JAVA

import java.util.Iterator; is used for Iterator usage in Salesforce web service API
using JAVA Program. 


Don't import other Iterator in Web Service API using JAVA Programming language.


Cheers!!!

Emptying recycle bin in salesforce

To empty recycle bin data in Salesforce using external application, emptyRecycleBin () method is used.

emptyRecycleBin ()

Delete records from the recycle bin immediately. The recycle bin lets you view and restore recently deleted records for 15 days before they are permanently deleted. Your Organization can have up to 5,000 records per license in the Recycle Bin at any one time. For example, if your organization has five user licenses, 25,000 records can be stored in the Recycle Bin. If your organization reaches its Recycle Bin limit, Salesforce automatically removes the oldest records, as long as they have been in the recycle bin for at least two hours. If you know you will be adding a great number of records to the Recycle Bin and you know you won't need to undelete () them, you may wish to remove them before the Salesforce process deletes records. For example, you can use this call if you are loading a large number of records for testing, or if you are doing a large number of create ()calls followed by delete() calls.

Syntax

EmptyRecycleBinResult[] = connection.emptyRecycleBin(ID[] ids);

where connection is an object of EnterpriseConnection.

Sample JAVA Program to empty recycle bin data in Salesforce

http://infallibletechie.blogspot.in/2012/11/emptying-recycle-bin-in-salesforce.html


Cheers!!!

Upserting data into Salesforce using Web Service API

To upsert data in Salesforce using external application, upsert () method is used.

upsert()

Creates new records and updates existing records; uses a custom field to determine the presence of existing records. In most cases, we recommend that you use upsert () instead of create() to avoid creating unwanted duplicate records (idempotent). You can process records for one more than object type in an create() or update()
call, but all records must have the same object type in an upsert () call.

Upsert is a merging of the words insert and update. This call is available for objects if the object has an external ID field or a field with the idLookup field property. On custom objects, this call uses an indexed custom field called an external ID to determine whether to create a new record or update an existing record. On standard objects, this call can use the name of any field with the idLookup field property instead of the external ID.

Note:

Starting with API version 15.0, if you specify a value for a field that contains a string, and the value is too big for the field, the call fails and an error is returned. In previous versions of the API the value was truncated and the call succeeded. If you wish to keep the old behavior with versions 15.0 and later, use the AllowFieldTruncationHeader SOAP header.

Syntax

UpsertResult[] = connection.upsert(String externalIdFieldName, sObject[] sObjects);



Cheers!!!

Updating data into Salesforce using Web Service API

To update data in Salesforce using external application, update () method is used.

update ()

Update one or more existing records in your organization’s data. Use this call to update one or more existing records, such as accounts or contacts, in your organization’s data. The update () call is analogous to the UPDATE statement in SQL.

Syntax

SaveResult[] = connection.update(sObject[] sObjects);

where connection is an object of EnterpriseConnection.



Cheers!!!

Inserting data into Salesforce using Web Service API

To insert data from external application to Salesforce, create() method is used.

create ()

create () add one or more new records to your organization’s data. Use create () to add one or more records, such as an Account or Contact record, to your organization’s information. create () call is analogous to the INSERT statement in SQL.

Syntax

SaveResult[] = connection.create(sObject[] sObjects);

where connection is an object of EnterpriseConnection.

Sample JAVA Program to Insert data into Salesforce

Cheers!!!

Deleting data from Salesforce using Web Service API

To delete data from Salesforce using external application, delete () method is used.

delete()

Delete one or more records from your organization’s data. Use delete () to delete one or more existing records, such as individual accounts or contacts, in your organization’s data. The delete () call is analogous to the DELETE statement in SQL.

Syntax

DeleteResult[] = connection.delete(ID[] ids);

where connection is an object of EnterpriseConnection.

Sample JAVA Program to delete data from Salesforce



Cheers!!!

Like operator in SOQL query in JAVA and C#

Example:

String sql = 'SELECT Name,Id FROM Account WHERE Name Like '%' + acctName + '%'';

Here 'acctName' is a variable.


Cheers!!!

Sample JAVA program for Web Service API

Sample Code:

package wsc;

import java.io.BufferedReader;

import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.IOException;

//import com.sforce.soap.enterprise.DeleteResult;

import com.sforce.soap.enterprise.DescribeGlobalResult;
import com.sforce.soap.enterprise.DescribeGlobalSObjectResult;
import com.sforce.soap.enterprise.DescribeSObjectResult;
import com.sforce.soap.enterprise.EnterpriseConnection;
//import com.sforce.soap.enterprise.Error;
import com.sforce.soap.enterprise.Field;
//import com.sforce.soap.enterprise.FieldType;
import com.sforce.soap.enterprise.GetUserInfoResult;
//import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.PicklistEntry;
import com.sforce.soap.enterprise.QueryResult;
//import com.sforce.soap.enterprise.SaveResult;
//import com.sforce.soap.enterprise.sobject.Account;
import com.sforce.soap.enterprise.sobject.Contact;
import com.sforce.soap.enterprise.sobject.SObject;
import com.sforce.ws.ConnectorConfig;
import com.sforce.ws.ConnectionException;

public class QuickstartApiSample

{
private static BufferedReader reader =
new BufferedReader(new InputStreamReader(System.in));
EnterpriseConnection con;
String authEndPoint = "";
String passwd = "";
public static void main(String[] args)
{   
QuickstartApiSample sample = new QuickstartApiSample("https://login.salesforce.com/services/Soap/c/24.0/0DF90000000PX8r");
if ( sample.login() )
{
sample.describeGlobalSample();
sample.describeSample();
sample.querySample();
}
}
public QuickstartApiSample(String authEndPoint)
{
this.authEndPoint = authEndPoint;
}
public String getUserInput(String prompt)
{
String result = "";
try
{
System.out.print(prompt);
result = reader.readLine();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
return result;
}
public boolean login()
{
boolean success = false;
String userId = getUserInput("UserID: ");
String passwd = getUserInput("Password: ");
try
{
ConnectorConfig config = new ConnectorConfig();
config.setAuthEndpoint(authEndPoint);
config.setUsername(userId);
config.setPassword(passwd);
config.setCompression(true);
//config.setProxy("Your Proxy", 80);
System.out.println("AuthEndPoint: " + authEndPoint);
config.setTraceFile("traceLogs.txt");
config.setTraceMessage(true);
config.setPrettyPrintXml(true);

con = new EnterpriseConnection(config);

GetUserInfoResult userInfo = con.getUserInfo();
System.out.println("\nLogging in ...\n");
System.out.println("UserID: " + userInfo.getUserId());
System.out.println("User Full Name: " +
userInfo.getUserFullName());
System.out.println("User Email: " +
userInfo.getUserEmail());
System.out.println();
System.out.println("SessionID: " +
config.getSessionId());
System.out.println("Auth End Point: " +
config.getAuthEndpoint());
System.out.println("Service End Point: " +
config.getServiceEndpoint());
System.out.println();
success = true;
}
catch (ConnectionException ce)
{
ce.printStackTrace();
}
catch (FileNotFoundException fnfe)
{
fnfe.printStackTrace();


}
return success;
}
public void logout()
{
try
{
con.logout();
System.out.println("Logged out");
}
catch (ConnectionException ce)
{
ce.printStackTrace();
}
}
/**
* To determine the objects that are available to the logged-in
* user, the sample client application executes a describeGlobal
* call, which returns all of the objects that are visible to
* the logged-in user. This call should not be made more than
* once per session, as the data returned from the call likely
* does not change frequently. The DescribeGlobalResult is
* simply echoed to the console.
*/
public void describeGlobalSample()
{
try
{
DescribeGlobalResult describeGlobalResult =
con.describeGlobal();
DescribeGlobalSObjectResult[] sobjectResults =
describeGlobalResult.getSobjects();
for (int i = 0; i < sobjectResults.length; i++)
{
System.out.println(sobjectResults[i].getName());
}
}
catch (ConnectionException ce)
{
ce.printStackTrace();
}
}
/**
* The following code segment illustrates the type of metadata
* information that can be obtained for each object available
* to the user. The sample client application executes a
* describeSObject call on a given object and then echoes
* the returned metadata information to the console. Object
* metadata information includes permissions, field types
* and length and available values for picklist fields
* and types for referenceTo fields.
*/
private void describeSample()
{
String objectToDescribe = getUserInput("\nType the name of the object to " +
"describe (Example: Account): ");
try
{
DescribeSObjectResult describeSObjectResult =
con.describeSObject(objectToDescribe);
if (describeSObjectResult != null)
{
Field[] fields = describeSObjectResult.getFields();
System.out.println("Metadata for the " +
describeSObjectResult.getName() + " SObject"
);
System.out.println("\tActivateable: " +
describeSObjectResult.isActivateable()
);
System.out.println("\tNumber of fields: " +
fields.length
);
if (fields != null)
{
for (Field field : fields)
{
//String name = field.getName();
System.out.println("\tField name: " +
field.getName()
);
PicklistEntry[] picklistValues =
field.getPicklistValues();
if (picklistValues != null && picklistValues.length > 0)
{
System.out.println("\t\tPicklist values: ");
for (int j = 0; j < picklistValues.length; j++)
{
if (picklistValues[j].getLabel() != null)
{
System.out.println("\t\tValue: " +
picklistValues[j].getLabel()
);
}
}
}
String[] referenceTos = field.getReferenceTo();
if (referenceTos != null && referenceTos.length > 0)
{
System.out.println("\t\tThis field references the " +
"following objects:"
);
for (int j = 0; j < referenceTos.length; j++)
{
System.out.println("\t\t" + referenceTos[j]);
}
}
}
}
}
}
catch (ConnectionException ce)
{
ce.printStackTrace();
}
}
public void querySample()
{
try
{
String soqlQuery = "SELECT FirstName, LastName FROM Contact";
QueryResult result = con.query(soqlQuery);
boolean done = false;
if (result.getSize() > 0)
{
System.out.println("\nLogged-in user can see " +
result.getRecords().length +
" contact records."
);
while (! done)
{
SObject[] records = result.getRecords();
for ( int i = 0; i < records.length; ++i )
{
Contact con = (Contact) records[i];
String fName = con.getFirstName();
String lName = con.getLastName();
if (fName == null)
{
System.out.println("Contact " + (i + 1) +
": " + lName
);
}
else
{
System.out.println("Contact " + (i + 1) + ": " +
fName + " " + lName
);
}
}
if (result.isDone())
{
done = true;
}
else
{
result =
con.queryMore(result.getQueryLocator());
}
}
}
else
{
System.out.println("No records found.");
}
System.out.println("\nQuery succesfully executed.");
}
catch (ConnectionException ce)
{
ce.printStackTrace();
}
}
}

Configuring Proxy Settings in Eclipse

1. In Eclipse IDE, select Window –> Preferences.


2. Preferences box prompt out, choose Network Connections.

3. Select Manual from Action Provider drop down list.

4. Select HTTP in the List and click Edit button.


5. Click Ok.

Note:

Give the username and password if any.

Cheers!!!

How do I configure proxy settings for Java?

  1. Click the Start menu
  2. Select Settings
  3. Select Control Panel
  4. Double click the Java icon.
  5. Click on the Network Settings button.
  6. Select the Use Browser Settings checkbox.
  7. Click the OK button to save your changes.
If it still shows error, check the browser settings.

Good luck.....

Cheers!!!

Authentication Endpoint : authEndpoint

https://login.salesforce.com/services/Soap/c/api_version is the new recommended endpoint for
API login requests, where api_version specifies the API version, such as 17.0.

If you send non-login requests to https://login.salesforce.com/services/Soap/c/api_version, an error is returned.The less secure version of the URL—http://login.salesforce.com/services/Soap/c/api_version—is also supported, but not recommended. It is helpful for debugging through proxy servers.


Cheers!!!

Error import com.sforce.soap.enterprise

Its a common error in Webservice api.
To avoid this error, you have to use the below syntax to create enterprise.jar.

Code:

java –classpath pathToJAR/wsc-20.jar com.sforce.ws.tools.wsdlc pathToWsdl/WsdlFilename
pathToJar/JarFilename

Example:

java -classpath wsc-20.jar com.sforce.ws.tools.wsdlc enterprise.wsdl.xml enterprise.jar

The above code generates a jar file named 'enterprise'.

You should include this jar file to avoid errors.


Cheers!!!

Exception in thread Main error in Java

Exception in thread Main error in Java means the class for particular java program has not been created.

So compile the Java program first. Find the errors and debug the errors.

Then only you will be able to execute the Java Program.


Cheers!!!

How to set class path in Command prompt for Java code


How to set class path in Command prompt for java code
set path = “C:\Program Files\Java\jdk1.6.0_12\bin”

To compile Java program:
javac progName.java
 
To Run Java program:
java progName


Cheers!!!

Web Service API in Salesforce

Salesforce has powerful CRM features. In order to extend this features, we go for Web Service API.

Steps to define API in Salesforce:

1. Go to Setup menu.
2. Develop --> API

Bulk API:
Used to create, retrieve, delete and update large amount of records.

REST API:
Mainly used for integration. It also maintains passwords.

Metadata API:
Mainly used for migration from sandbox to production.

SOAP API:
Used to create, retrieve, delete and update records.


Cheers!!!