Concepts or coding lessons of Salesforce that you can implement easily

Salesforce Interview Questions - Part 2

31. What is a report type?
Answer - A report type is a skeleton over which you can build the report. It specify the structure of your report(Object relationship). Salesforce provides standard report types using which reports can be build. If the standard type does not suffice your requirement then we have to go for custom report type. It allows to build framework from which reports can be created. While building report type we need to select object and the relationship between objects to display in report. Which fields will be available for display can also be set.

32. What are analytical snapshot?
Answer - Analytical snapshots can be used to schedule a report run and then save the report result as records in custom object. While building a analytical snapshot we have to select a source report and destination object. Then map the fields from report and object. The report runs at specified time and then inserts the report result as records in that object. Advantages that we get through analytical snapshot are as below, Runs reports faster, Sort and filter data using list views, can view trend in data via object records. The object selected for record insertion should not have any insert trigger on it.

Accelerate Career in Salesforce with Enterprise Architecture !!! 

33. What are various standard exceptions that salesforce throws?
Answer - salesforce throws number of standard exception . Some of the important ones are as below-
dmlexception, listexception, email exception, calloutexception, JSONexception, mathexception, Queryexception, sObjectexception, xmlexception, typeexception, visualforceexception, stringexception, searchexception, nullpointerexception, noaccessexception.
34. What are the various ways of deployment in salesforce?
Answer - Metadata components in salesforce can be deployed using various ways as below
         Change set, Eclipse IDE, ANT, Workbench  

35. How can you expose a apex class as web service? and how to obtain a wsdl file for exposed class?
Answer - In order to expose a class as a webservice we have to use keyword 'webservice' with the method also the method should be global and also the class should be defined global. ex-
Global class DemoWebServiceClass{
 global webservices void myWebServiceMethod(){
A wsdl file for a apex class can be obtained by using the button generate wsdl on class.
Learn how to on my another blog post: 7 Easy Steps to Generate Apex Class From WSDL In Salesforce

36. What is an account team?
Answer - Account team is group of users that work on a articular account. The users in a account team can be given access depending on the need. A account team appears as related list on account.

Build robust and scalable code architectures on the platform, for more information click Apex Design Patterns

37. What are the Different API's in salesforce ?
Chatter REST API :
Chatter REST API provides programmatic access to Chatter feeds and social data such as users, groups, followers, and files. Use Chatter REST API to integrate Chatter into a variety of applications such as mobile applications, third-party Web apps and intranet sites.

This api is used for accessing objects in organization through REST. Data format used is JSON, XML and communicates Synchronously. We can use this whenever we want to leverage the REST architecture to integrate with the salesforce environment. There is No WSDL required while using REST API. This is well-suited for browser based applications, mobile appslication, and social apps they are more interactive. It is uses REST protocol.
The Bulk API provides a programmatic option to quickly load your org’s data into Salesforce. Bulk API is based on REST principles and is optimized for loading or deleting large sets of data. You can use it to query, queryAll, insert, update, upsert, or delete many records asynchronously by submitting batches. Salesforce processes batches in the background.

SOAP API provides a powerful, convenient, and simple SOAP-based web services interface for interacting with Salesforce. Protocol used is SOAP/WSDL, format is XML and communicates Synchronously. You can use SOAP API to create, retrieve, update, or delete records. You can also use SOAP API to perform searches and much more. Use SOAP API in any language that supports web services.

Metadata API is intended for managing customizations and for building tools that can manage the metadata model, not the data itself. Here the SOAP API is oriented around accessing data and manipulating records, the Metadata API’s focuses on metadata. It gives you an API to manipulate layouts, classes, visualforce pages, Apex triggers. Protocol used is SOAP/WSDL. Format used is XML and communicates Asynchronously.

Tooling API :
This is used when one wants to manage and deploy working copies of Apex classes or triggers or Visualforce pages or other components.

Streaming API :
Use Streaming API to receive notifications for changes to Salesforce data that match a SOQL query you define, in a secure and scalable way. This enables one to reduce the number of API calls and improve performance.

38. What is the default batch size if we enable bulk API?
Answer : 2,000 records.

39. What is recursive workflow rule? How to avoid recursive workflow rules?

Whenever you enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update of a workflow rule, due to this field update other workflow rules on the same object will be fired if the entry criteria of those workflow rules satisfied.

And , You have other workflow rules also if you enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update recursive workflow rules will come in some scenarios.

We can take two steps to avoid recursive workflow rules :
  • For the workflow Evaluation Criteria if you choose created, and any time it’s edited to subsequently meet criteria option, we can avoid recursive workflow rules.
  • If you don't enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update of a workflow rule we can avoid.
40. What is the difference between database.insert and insert?
Answer :
Both DML statements perform same operation i.e. insert records.
Insert is the DML statement which is same as databse.insert.
However, database.insert gives more flexibility like rollback, default assignment rules etc. we can achieve the database.insert behavior in insert by using the method setOptions(Database.DMLOptions).

Important Difference:

If we use the DML statement (insert), then in bulk operation if error occurs, the execution will stop and Apex code throws an error which can be handled in try catch block.
If DML database methods (Database.insert) used, then if error occurs the remaining records will be inserted / updated means partial DML operation will be done.

41. What is the difference between 15 digit and 18 digit IDs in Salesforce?
15 digit ID in is case sensitive and 18 Digit Id is case-insensitive. Many applications does not support case sensitive strings, so in that case we can make use of 18 digit Id which is case in-sensitive.
15 digit Id number will have numeric digits range from (0-9), a Lowercase letter(a-z) or a Uppercase letters(A-Z). 15 digit ID in is case sensitive. Example 999999999999ABC  is different from 999999999999abc. When using external productive tools like Microsoft Excel, MS Access and SQL Server external ID’s are not case sensitive and they don’t recognize the difference between 999999999999ABC  and 999999999999abc. has recognized this problem and has established 18 digit character insensitive ID. This 18 Digit ID is case insensitive which is formed by adding a suffix to the 15 Character Id number.

42. What are different types of reports?
Tabular: Tabular reports are the simplest and fastest way to look at data. Similar to a spreadsheet, they consist simply of an ordered set of fields in columns, with each matching record listed in a row. Tabular reports are best for creating lists of records or a list with a single grand total. They can't be used to create groups of data or charts, and can't be used in dashboards unless rows are limited. Examples include contact mailing lists and activity reports.
Summary: Summary reports are similar to tabular reports, but also allow users to group rows of data, view subtotals, and create charts. They can be used as the source report for dashboard components. Use this type for a report to show subtotals based on the value of a particular field or when you want to create a hierarchical list, such as all opportunities for your team, subtotaled by Stage and Owner. Summary reports with no groupings show as tabular reports on the report run page.
Matrix: Matrix reports are similar to summary reports but allow you to group and summarize data by both rows and columns. They can be used as the source report for dashboard components. Use this type for comparing related totals, especially if you have large amounts of data to summarize and you need to compare values in several different fields, or you want to look at data by date and by product, person, or geography. Matrix reports without at least one row and one column grouping show as summary reports on the report run page.
Joined: Joined reports let you create multiple report blocks that provide different views of your data. Each block acts like a “sub-report,” with its own fields, columns, sorting, and filtering. A joined report can even contain data from different report types.
43. What are different kinds of dashboard component?
Table: Use a table to show a set of report data in column form.
Visualforce Page: Use a Visualforce page when you want to create a custom component or show information not available in another component type
Custom S-Control: Custom S-Controls can contain any type of content that you can display or run in a browser, for example, a Java applet, an ActiveX control, an Excel file, or a custom HTML Web form.
Chart: Use a chart when you want to show data graphically.
Metric: Use a metric when you have one key value to display.
Enter metric labels directly on components by clicking the empty text field next to the grand total.
Metric components placed directly above and below each other in a dashboard column are displayed together as a single component.
Gauge: Use a gauge when you have a single value that you want to show within a range of custom values.

44. What is the maximum size of the PDF generated on visualforce attribute renderAs ?
Answer : 15 MB

45. What is the System.runAs() ?
Answer :
Generally, all Apex code runs in system mode, and the permissions and record sharing of the current user are not taken into account. The system method, System.runAs(), lets you write test methods that change user contexts to either an existing user or a new user. All of that user’s record sharing is then enforced. You can only use runAs in a test method. The original system context is started again after all runAs() test methods complete.
Example :
System.runAs(u) {
// The following code runs as user 'nitish'
System.debug('Current User: ' + UserInfo.getUserName());
System.debug('Current Profile: ' + UserInfo.getProfileId()); 
// Run some code that checks record sharing

46. What is Difference in render, rerender and renderas attributes of visualforce?
Answer :
render : It works like display property of CSS. It is used to show or hide element on visualforce page.
rerender : After Ajax which component should be refreshed – This attribute is available on commandlink, commandbutton, actionsupport .
renderas : render page as PDF, DOC and Excel. With the help of this attribute you can download the data display on visualforce page.

47. When Group By is used, How to write or use the Where clause in SOQL ?
Answer :
We cannot use the Where clause with Group By instead we will need to use the Having Clause.

48. If user does not have any right on particular record and have only read level access at object level. Can he change the record owner?
Answer :
Yes. In profile, there is setting for Transfer Record.

49. Explain the use of Test.setPage() ?
Answer :
It is used to set the context to current page, normally used for testing the visual force controller.

50. Can you use Group by clause inside inner query in SOQL? like SELECT Id, Name,(SELECT Count(Id),Name FROM Contacts Group By Name Having Count(Id) > 1 )
Answer :
No. Only root queries support aggregate expressions. Return type is List<AggregateResult> for above query However the root result expects List<Account> and there is no syntax or provision available in Salesforce to specify that child results are of type AggregateResult.

More Salesforce Interview Questions and Answers:


1 comment: