How to show error message from validation rules and triggers in Visualforce page without try and catch block in Salesforce.com?

It is not possible as of now.

Cheers!

Salesforce Interview questions with answers Part 22

1. What are all the relationships available in salesforce?

Master Detail
Lookup

2. How to create 1 to 1 relation ship?

Create a rollup of count field in Master object. If it greter than 1, we should not allow it to insert.

3. How to create master detail relationship?

From the child object, we have to create Master Detail field and select the master object.


4. How to show trigger error message in Visualforce page, if we do DML using Controller and VF Page?

http://www.infallibletechie.com/2013/04/how-to-add-error-message-in-visualforce.html

5. What is custom settings?

http://www.infallibletechie.com/2013/04/custom-settings-in-salesforce.html

6. Can we deploy the custom settings?

Yes custom settings can be deployed.

7. Can we move profiles through changeset?


Yes.

8. What are the problems involve when we move through profiles via change set?


Administration permissions, Tab settings and Object settings cannot be moved.

9. why we go for record types? why not we can achieve this only through page layouts?


1. To filter picklist values
2. Assigning page layouts to profiles

10. What is the use of Historical trend reporting?

http://www.infallibletechie.com/2014/02/historical-trend-reporting-in-salesforce.html


11. Explain about account teams? 

Account teams are used to share account records to account team members.

How to add multiple users in Salesforce?

1. Go to Setup --> Administer --> Manage Users --> Users.

2. Click "Add Multiple Users".


3. Select the user license. In developer edition, choose Salesforce platform.


4. Enter the details and click "Save" button.


DescribeSObjectResult in Salesforce

Sample Code:

DescribeSObjectResult sobjectRes = Employee__c.sObjectType.getDescribe();
system.debug('Object Label is ' + sobjectRes.getLabel());
system.debug('Key prefix is ' + sobjectRes.getKeyPrefix());
system.debug('Plural Label is ' + sobjectRes.getLabelPlural());
system.debug('Object Name is ' + sobjectRes.getName());
system.debug('Is Object queryable by current user? ' + sobjectRes.isQueryable());
system.debug('Is Object updateable by current user? ' + sobjectRes.isUpdateable());          

Output:




Cheers!!!

Schema Namespace in Salesforce

The Schema namespace provides classes and methods for schema metadata information.

The following are the classes in the Schema namespace.
  1. ChildRelationship Class 
  2. DataCategory Class 
  3. DataCategoryGroupSobjectTypePair Class 
  4. DescribeColorResult Class 
  5. Describe​DataCategoryGroupResult Class 
  6. Describe​DataCategoryGroupStructureResult Class 
  7. DescribeFieldResult Class 
  8. DescribeIconResult Class 
  9. DescribeSObjectResult Class 
  10. DescribeTabResult Class 
  11. DescribeTabSetResult Class 
  12. DisplayType Enum 
  13. FieldSet Class 
  14. FieldSetMember Class 
  15. PicklistEntry Class 
  16. RecordTypeInfo Class
  17. SOAPType Enum 
  18. SObjectField Class 
  19. SObjectType Class 

Cheers!!!

Mass Transfer records in Salesforce

1. Go to Setup --> Administer --> Data Management --> Mass Transfer Records.


2. Select the object.


3. Enter the criteria and click "Find" button to find the records.


4. Click "Transfer" button to transfer the records.


Cheers!!!

Storage usage in Salesforce

Storage usage is used to find the organization's storage usage.




Difference between Future annotation and Batch apex

Future Annotation
Batch Apex
Future Annotation is used to separate methods that are to be executed asynchronously.
Batch Apex is used to separate tasks that are going to handle more records in background process. Batch Apex also runs asynchronously
If Future Annotation is not used in a web service callout, the thread will wait until the response comes and other processes will not be executed.
If Batch Apex is not used for handling bulk records, we will hit governor limits set by Salesforce.com.


Queue and Public Group

Queue
Public Group
Queue is used for load balancing
Public Group is solely used for sharing
Queue is a feature available to salesforce.com users that allows you to integrate prospect assignments with your current salesforce.com workflow. Rather than assigning to a specific user, you can choose to assign leads to a salesforce.com queue and then use your CRM workflow or manual method of distributing leads to sales representatives.
Public Group is kind of team or group of related users; this will help you to share the data.
Queue can be created for Custom objects and for Case, Lead and Knowledge Article Version.
Public group created can be used across any objects.

Queue:



Public Group:



Cheers!!!

Mass Delete Records in Salesforce

1. Go to Setup --> Admin Setup --> Data Management --> Mass Delete Records.


2. Select which object you want to delete.

3. Enter the criteria to search the records.


4. Select the records and click "Delete" button to delete the records.


Auto response rule in Salesforce

An auto-response rule is a set of conditions for sending automatic email responses to lead or case submissions based on the attributes of the submitted record. Applicable leads include those captured through a Web-to-Lead form. Applicable cases include those submitted through a:
  • Self-Service portal
  • Customer Portal
  • Web-to-Case form
  • Email-to-Case message
  • On-Demand Email-to-Case message
You can create as many response rules as you like based on any attribute of the incoming lead or case, but only one rule for leads and one for cases can be active at a time.

1. Create required email templates.



2. Go Setup --> Build --> Customize --> Leads --> Auto-Response Rules.


3. Click "New" button.


4. Give a name, check "Set this as the active Web-to-Lead Auto-Response rule" check box and click "Save" button.


5. Open the Auto - Response Rule.


6. Click "New" to create rule entries.


7. Below is the list of rule entries.


8. Create a sample Lead from Web to Lead form.


Output:



Assignment rule in Salesforce

Create assignment rules to automate your organization’s lead generation and support processes.
  • Lead Assignment RulesSpecify how leads are assigned to users or queues as they are created manually, captured from the web, or imported via the lead import wizards.
  • Case Assignment RulesDetermine how cases are assigned to users or put into queues as they are created manually, using Web-to-Case, Email-to-Case, On-Demand Email-to-Case, the Self-Service portal, the Customer Portal, Outlook, or Lotus Notes.

Steps for creating Lead Assignment Rule:

1. Go to Setup --> Build --> Customize --> Leads --> Assignment Rule.



2. Click "New" button.




3. Give a name, check "Set this as the active lead assignment rule" check box.




4. Open the assignment rule.


5. Click "New" to create a rule entry.



6. Enter the criteria as per your requirement.




7. Below is the output of my rule criteria.




8. Go to Leads tab. Create a Lead record. Check "Assign using active assignment rule" check box.





Output:




This lead record is assigned to Magulan D because the Lead city is Chennai.

Search filter fields in Salesforce

Search filter fields allow us to filter the records that are retrieved after searching from the search bar.

1. Go to Search Filter fields.


2. Select the fields and click "Save" button.


3. Search a record.


4. Click "Show Filters".


5. You can filter the retrieved records.


Conditional rendered with list size Salesforce

Sample Code:

<apex:pageBlockTable value="{!empList}" var="emp" rendered="{! IF(empList.size > 0, true, false)}">
<apex:column value="{!emp.Name}"/>
<apex:column value="{!emp.Age}"/>
</apex:pageBlockTable>

the pageblock will be rendered only if the empList list size from the controller is greater than zero.

Cheers!!!

Date and Date time in Salesforce

Date:
Date dat = System.today();  //Returns today's date
Date dt = dat.addDays(2);  // Returns day after tomorrow's date

Datetime:
Datetime dt = System.now();  // Returns current date and time
Datetime dt1 = dt.addHours(2);  // Returns 2 hours ahead of current date and time 

REST API example in Salesforce

Representational State Transfer (REST) is a style of software architecture for distributed systems such as the World Wide Web. REST has emerged as a predominant web service design model.

REST-style architectures consist of clients and servers. Clients initiate requests to servers; servers process requests and return appropriate responses. Requests and responses are built around the transfer of representations of resources.

The Force.comREST API provides you with a powerful, convenient, and simple Web services API for interacting with Force.com. Its advantages include ease of integration and development, and it is an excellent choice of technology for use with mobile applications and Web 2.0 projects. However, if you have large numbers of records to process, you may wish to use Bulk API, which is based on REST principles and optimized for large sets of data.

Follow the below steps to experience REST call from JAVA to Salesforce.com

1. Open eclipse. Go to Window --> Preferences.



2. Go to JAVA --> Build Path --> User Libraries and click "New" button.



3. Give a name and click "OK" button.



4. Click "Add JARs" button. Add the JARs in the below Zip file and click "Ok" button.

Zip file for JARs : Click here to download.



5. Go to File --> New --> JAVA Project.


6. Give a name to the project and click "Finish" button.



7. Right click the project and go to Build Path --> Add Libraries.



8. Select "User Library".



9. Select the Library created and click "Finish" button.



10. Right click the Project --> New --> Package.



11. Give a name to the Package and click "Finish" button.



12. Right click the Package --> New --> Class.



13. Give a name to the class and click "Finish" button.



Use the below links for sample JAVA classes for REST API