Tuesday, August 11, 2015

Questions and Answer ??

2.     What is Sales Cloud and Service Cloud ?

Sales Cloud: It refers to the “sales” module in salesforce.com. It includes Leads, Accounts, Contacts, Contracts, Opportunities, Products, Pricebooks, Quotes, and Campaigns (limits apply). It includes features such as Web-to-lead to support online lead capture, with auto-response rules. It is designed to be a start-to-end setup for the entire sales process; you use this to help generate revenue.


Service Cloud: It refers to the “service” (as in “customer service”) module in salesforce.com. It includes Accounts, Contacts, Cases, and Solutions. It also encompasses features such as the Public Knowledge Base, Web-to-case, Call Center, and the Self-Service Portal, as well as customer service automation (e.g. escalation rules, assignment rules). It is designed to allow you to support past, current, and future clients’ requests for assistance with a product, service, billing, etcetra; you use this to help make people happy.


ROLLUP SUMMARY WITH A LOOKUP FIELD - SALESFORCE

1) Master-Detail
  Creates a special type of parent-child relationship between this object (the child, or “detail”) and another object (the parent, or “master”) where:
  - The relationship field is required on all detail records.
  - The ownership and sharing of a detail record are determined by the master record.
  - When a user deletes the master record, all detail records are deleted.
  - You can create rollup summary fields on the master record to summarize the detail records.
  The relationship field allows users to click on a lookup icon to select a value from a popup list. The master object is the source of the values in the list.
2)Lookup
  Creates a relationship that links this object to another object. The relationship field allows users to click on a lookup icon to select a value from a popup list. The other object is the source of the values in the list.
So let’s say that you know you are going to want to do a count on the number of child records.  The first thing we should try to do it to create a Master-Detail relationship between the parent and child object so that we can use the ‘out-of-the-box’ roll-up summary field to do the count calculation.
But sometimes a Master-Detail relationship is not allowed.  Why would that be?
1)  An object may only have two Master-Detail relationships. 
2) A standard object cannot be the child/detail in a Master-Detail relationship.  An example is that you cannot create a Master-Detail relationship from the Asset object because the Asset cannot be the child in a Master-Detail relationship.
Let’s have a specific example.  So let’s say you have a classroom object and a desk object.  Normally this would be setup as a Master-Detail relationship so that we could easily create a roll-up summary field to count the number of desks in the classroom.  But maybe the desk object already has two Master-Detail fields on it because it is in a relationship with the School and District objects.  Of course you can beg and plead with those who already used up those two Master-Detail relationships, but let’s assume that conversation had a quick ‘No’ as the answer.  So now you are stuck with using the lookup object. 
How are you going to get a count of the number of desks in a classroom?  It is going to take some trigger work and a helper class, but it can be done.  Here are your steps..



6. What are Apex Governor Limits?
Governor limits are runtime limits enforced by the Apex runtime engine. Because Apex runs in a shared, multitenant environment, the Apex runtime engine strictly enforces a number of limits to ensure that code does not monopolize shared resources. Types of limits that Apex enforces are resources like memory, database resources, number of script statements to avoid infinite loops, and number of records being processed. If code exceeds a limit, the associated governor issues a runtime exception.

14. What are the types of email templates available in salesforce.com?
·         Text
·         HTML with Letter Head
·         Custom HTML
·         Visual force

16. What is Roll up summary field in Salesforce?
Roll up summary field in salesforce calculates the Count, Sum, Min or Max of particular field of any child record. Thus, we can say that Roll up summary field can only be created on Master object.
Note : Roll up summary field can only be defined on the master object.

18. How many types of the relationship fields available in Salesforce?
·         Master Detail
·         Many to Many
·         Lookup
·         Hierarchical (It is available only on User Object, we cannot create this relationship)



19. How to create many to many relationships between object?
Creating many to many relationship in salesforce is little tricky. You cannot create this type of relationship directly. Follow below steps to create this type of relationship.
·         Create both objects which should be interlinked.
·         Create one custom object (also called as junction object), which should have autonumber as unique identification and create two master relationships for both objects, no need create tab for this object.
·         Now on both object, add this field as related list.
Few important points (Interview Questions of salesforce ):
  1. One Object can have only two Master-Detail relationships.
  2. If we delete record A (First Master detail relationship is always primary)  – then child record c will be deleted.
  3. If we delete record B then in this case also child record C will be deleted.
  4. If we delete record c then only C will be deleted, master record will not be deleted.
  5. If child C has two Master record A and B, Where A is primary relation then Child record C will inherit the look and feel of Parent object A.

20. In Which sequence Trigger and automation rules run in Salesforce.com 
The following is the order salesforce logic is applied to a record.
1)        Old record loaded from database (or initialized for new inserts)
2)        New record values overwrite old values
3)        System Validation Rules
4)        All Apex “before” triggers (EE / UE only)
5)        Custom Validation Rules
6)        Record saved to database (but not committed)
7)        Record reloaded from database
8)        All Apex “after” triggers (EE / UE only)
9)        Assignment rules
10)     Auto-response rules
11)     Workflow rules
12)     Escalation rules
13)     Parent Rollup Summary Formula value updated (if present)
14)     Database commit
15)     Post-commit logic (sending email)
Additional notes: There is no way to control the order of execution within each group above
21. If one object in Salesforce have 2 triggers which runs “before insert”. Is there any way to control the sequence of execution of these triggers?
Ans : Salesforce.com has documented that trigger sequence cannot be predefined. As a best practice create one trigger per object and use comment blocks to separate different logic blocks. By having all logic in one trigger you may also be able to optimize on your SOQL queries.
22. How to delete the User from Salesforce?
Ans : As per now, salesforce does not allow to delete any user, however you can deactivate the user.
23. How to delete the users data from Salesforce?
Ans : To delete the Users Data go to Setup | Administration Setup | Data Management | Mass Delete Record, from there select the objects like Account, Lead etc and in criteria select the users name and delete all records of that user related to particular object.
24. How to restrict the user to see any record, lets say opportunity?
Ans : set up opportunity sharing to be private.  If both users are admins or have view all records on opportunity, then that overrides private sharing.
25. What is the difference between trigger.new and trigger.old in Apex – SFDC?
Trigger.new :
Returns a list of the new versions of the sObject records.
Note that this sObject list is only available in
insert and
update triggers, and the records can only be modified in
beforetriggers.
Trigger.old :
Returns a list of the old versions of the sObject records.
Note that this sObject list is only available in
update and
delete triggers.





26. Salesforce provides two WSDL files, what are the differences?

Salesforce provides a WSDL (Web Service Description Language) files. They are called "Enterprise WSDL" and "Partner WSDL". A WSDL is an XML-document which contains a standardized description on how to communicate using a web service (the Salesforce API is exposed as a web service). The WSDL is used by developers to aid in the creation of Salesforce integration pieces. A typical process involves using the Development Environment (eg, Eclipse for Java, or Visual Studio for .Net) to consume the WSDL, and generate classes which are then referenced in the integration.
The primary differences between the two WSDL that we provide are:

Enterprise WSDL:
a) The Enterprise WSDL is strongly typed.
b) The Enterprise WSDL is tied (bound) to a specific configuration of Salesforce (ie. a specific organization's Salesforce configuration).
c) The Enterprise WSDL changes if modifications (e.g custom fields or custom objects) are made to an organization's Salesforce configuration.

For the reasons outlined above, the Enterprise WSDL is intended primarily for Customers.

Partner WSDL:
a) The Partner WSDL is loosely typed.
b) The Partner WSDL can be used to reflect against/interrogate any configuration of Salesforce (ie. any organization's Salesforce configuration).
c) The Partner WSDL is static, and hence does not change if modifications are made to an organization's Salesforce configuration.

For the reasons outlined above, the Partner WSDL is intended primarily for Partners.

To download a WSDL file when logged into Salesforce:

1. Click Setup | Customize | Develop | API 
2. Click the link to download the appropriate WSDL.
3. Save the file locally, giving the file a ".wsdl" extension.
Enterprise WSDL - This WSDL document is for customers who want to build an integration with their Salesforce organization only.It is strongly typed, which means that it contains objects and fields with specific data types, such as int and string. Customers who use the enterprise WSDL document must download and re-consume it whenever their organization makes a change to its custom objects or fields or whenever they want to use a different version of the API.
Partner WSDL - This WSDL document is for customers, partners, and ISVs who want to build an integration that can work across multiple Salesforce organizations, regardless of their custom objects or fields. It is loosely typed, which means that you work with name-value pairs of field names and values instead of specific data types. The partner WSDL document only needs to be downloaded and consumed once per version of the API

26. How to restrict any Trigger to fire only once ?
Triggers can fire twice, once before workflows and once after workflows, this is documented at
“The before and after triggers fire one more time only if something needs to be updated. If the fields have already been set to a value, the triggers are not fired again.”
Workaround:
Add a static boolean variable to a class, and check its value within the affected triggers.
public class HelperClass {
public static boolean firstRun = true;
trigger affectedTrigger on Account (before delete, after delete, after undelete) {
    if(Trigger.isBefore){
        if(Trigger.isDelete){
            if(HelperClass.firstRun){
                Trigger.old[0].addError('Before Account Delete Error');
                HelperClass.firstRun=false;
            }
        }
    }
}

28. Where is the option of the report for the “Custom Object with related object” and what are the condition to generate related reports?
Ans :- If the parent object is the standard object provided by the salesforce like “Account”, “Contact” then the report will be in there section with related custom object.
If both objects are the custom then the report will be in “Other Reports” Sections.
Following are the conditions to get the report of related objects:
Ø  On both the objects, Reports option must be enable.
Ø  The relationship between both of them must be “Master – detail relationship”.

35 How to display error messages in the visualforce page ?
Ans:
In Apex use below code to create the error message for visualforce.
Apexpages.addMessage( new ApexPages.Message (ApexPages.Severity.ERROR,'Required fields are missing. '));
in Visualforce page add below tag where you want to display the error message.

36 : What is property in Apex? Explain with advantages.
Ans:
Apex mainly consist of the syntax from the well known programming language Java. As a practice ofencapsulation in java we declare any variable as private and then creates the setters and getters for that variable.
private String name;
public void setName(String n)
{
  name = n;
}
public String getName()
{
 return name;
}
However, the Apex introduced the new concept of property from language C# as shown below:
           
public String name {get; set;}

As we can see how simple the code is and instead of using nearly 8 to 11 lines all done in 1 line only. It will be very useful when lots of member is declared in Apex class. It has another advantage in “number of lines of code” limit by salesforce which will drastically reduced.
37 : What is the controller extension ?
Ans:
Any apex class having a public constructor with Custom Controller or Standard Controller object as a single argument is known as controller extension.

38 : Explain the need or importance of the controller extension.
Ans:
Controller extension is very useful and important concept introduced by the salesforce recently. It gives the power to programmer to extend the functionality of existing custom controller or standard controller.
A Visualforce can have a single Custom controller or standard controller but many controller extensions.
We can say that the custom extension is the supporter of custom or standard controller.
Consider one example : If there is one controller written and used by the multiple visualforce pages and one of them needs some extra logic. Then instead of writing that logic to controller class (Which is used by many visualforce pages) we can create a controller extension and apply to that page only.

39 : How to read the parameter value from the URL in Apex?
Ans:
Consider that the parameter name is “RecordType”.
String recordType = Apexpages.currentPage().getParameters().get('RecordType');

40. What is Master Detail relationship and look up relationship in Salesforce?
Ans:
Master Detail relationship is the Parent child relationship. In which Master represents Parent and detail represents Child. If Parent is deleted then Child also gets deleted. Rollup summary fields can only be created on Master records which will calculate the SUM, AVG, MIN of the Child records.
Look up relationship is something like “has-a” (Containership) relationship. Where one record has reference to other records. When one record is deleted then there is no impact on other records.

41. Can we convert the lookup relationship to Master Detail relationship?
Ans:
We can convert the lookup relationship to master detail relationship if and only if all the existing record has valid lookup field.
·         You can convert a look up to master detail provided if your existing data look ups contain data for all records,
·         Also you should have "Allow reparenting' check box checked for that field otherwise you will find master detail disabled when you try to change the data tyoe to master detail.
One of the most advantage using Master-Detail relationship compare to Lookup relationship is Roll-Up Summary. In Master-Detail relationship, we can create roll-up summary field in master record to summarize / count data from child records. I wrote a blog earlier for Master-Detail relationship.
More items to notice when create roll-up summary field:
Parent record is locked
If you implement approval process with lock record in master object, user will not able to create new child record if Sharing Setting in Master-Detail option is Read/Write.
Solution: change the sharing setting to Read Only.


Validation rule on parent record
If user not able to edit parent record because of validation rule, and you have roll-up summary in parent record, user will not able to create or edit child record.
Solution: remove roll-up summary fields.


Can I change field type from Master-Detail to Lookup relationship?
Yes, make sure there is no roll-up summary fields in parent record, also in Deleted Fields (erase from Deleted Fields).


Can I change field type from Lookup to Master-Detail relationship?
Yes, all parent record should be not blank.

43. Can we create Master Detail relationship on existing records?
Ans:
No. As discussed above, first we have to create the lookup relationship then populate the value on all existing record and then convert it.
44. How validation rules executed? is it page layout / Visualforce dependent?
Ans :
The validation rules run at the data model level, so they are not affected by the UI. Any record that is saved in Salesforce will run through the validation rules.
45. What is the difference between database.insert and insert ?
Ans:
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:
o   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.
o   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.
49. What is Difference in render, rerender and renderas attributes of visualforce?
Ans :
render – It works like “display” property of CSS. Used to show or hide element.
rerender – After Ajax which component should be refreshed – available on
commandlink, commandbutton, actionsupport etc.
renderas – render page as pdf, doc and excel.
50. What is Scheduler class in Apex?
Ans:
The Apex class which is programed to run at pre defined interval.
Class must implement schedulable interface and it contains method named execute().
There are two ways to invoke schedular :
Ø  Using UI
Ø  Using System.schedule
The class which implements interface schedulable get the button texted with “Schedule”, when user clicks on that button, new interface opens to schedule the classes which implements that interface.
To see what happened to scheduled job, go to “Monitoring | Scheduled jobs “
Example of scheduling :  
scheduledMerge m = new scheduledMerge();
String sch = '20 30 8 10 2 ?';         
system.schedule('Merge Job', sch, m);

52. What is the difference between External ID and Unique ID?
Ans:
External ID
This is a field that usually references an ID from another (external) system. For instance, if the customer has an Oracle Financials system that they will be linking with salesforce.com, it may be easier for them to be able to refer to the Oracle ID of account records from within salesforce. So they would create an external ID in salesforce.com and they would load the Oracle ID into that field for each account. They can then refer to that ID field, rather than the salesforce.com id.
Additionally, if you have an external ID field, the field becomes searchable in the sidebar search. You also can use the upsert API call with the extenal ID to refer to records.
You can have multiple records with the same external ID (though it is not reccomended, as it will defeat the purpose of the external id) .
External Id available for Text, Number and Email field types.
External Id is used in upsert operations.
o   If external id is absent or not matched then insert happens.
o   If external id matched once then record will be updated.
o   If external id is matched multiple times then error occurs.

Unique ID
This is a setting for the field that will prevent you from using the same value in multiple records for the unique field. So if I create a 5 character text field and make it unique, and I create a record with the value “12345’’, I will not be able to create another record with that same value in the unique field. If I try to do so, I will get an error saying that the value is already in use.
53. How to get the picklist value in Apex class?
Ans :
Using Dynamic apex, we can achieve this on object of type pickilist, call getDescribe(). then call the getPicklistValues() method. iterate over result and create a list. bind it to .

54. What are the types of controller in visual force?
Ans:  There are basically two types of Controller in Visual force page.
a.   Standard Controller and
b.   Custom Controller
55. How many Controllers can be used on single VF page?
Ans :
Only one controller can be used salesforce. Other than them, Controller extension can be used. There may be more than one Controller extention.
Example :
           

if ExtOne and ExtTwo, both have the method getDetaill() then the method of ExtOne will be executed.
A controller extension is any Apex class that contains a constructor that takes a single argument of type ApexPages.StandardController or CustomControllerName, where CustomControllerName is the name of a custom controller that you want to extend.




56. Explain System.runAs()
Ans :

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 'u'
System.debug('Current User: ' + UserInfo.getUserName());

System.debug('Current Profile: ' + UserInfo.getProfileId()); }
// Run some code that checks record sharing
}


57. Explain Test.setPage()
Ans:
It is used to set the context to current page, normally used for testing the visual force controller.

58. What is the custom settings ?
Ans : 
Custom settings are similar to custom objects and enable application developers to
create custom sets of data, as well as create and associate custom data for an organization, profile, or specific user. All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. This data can then be used by formula fields, validation rules, Apex, and the Web services API.
59. Types of the custom settings?
Ans : 
List Custom Settings
A type of custom setting that provides a reusable set of static data that can be accessed across your organization. If you use a particular set of data frequently within your application, putting that data in a list custom setting streamlines access to it. Data in list settings does not vary with profile or user, but is available organization-wide. Examples of list data include two-letter state abbreviations, international dialing prefixes, and catalog numbers for products. Because the data is cached, access is low-cost and efficient: you don’t have to use SOQL queries that count against your governor limits.

Hierarchy Custom Settings
A type of custom setting that uses a built-in hierarchical logic that lets you “personalize” settings for specific profiles or users. The hierarchy logic checks the organization, profile, and user settings for the current user and returns the most specific, or “lowest,” value. In the hierarchy, settings for an organization are overridden by profile settings, which, in turn, are overridden by user settings.

60. Difference between SOSL and SOQL in Salesforce ?
Ans :

SOSL

SOQL

stands for "Salesforce object search language".

stands for "Salesforce object query language".

Works on multiple object at a same time.

Need to write different SOQL for different object.

All fields are already text indexed.

SOQL against same field will be slow.

Cannot used in Triggers. Can only be used in Apex class and anonymous block.

Can be used in Apex class and Triggers.


62.In Profile settings, what is difference between “Modify All Data” and “Modify All” ?

Ans:
Modify All Data : Create, edit, and delete all organization data, regardless of sharing settings.
Modify All : Give All (Read, Create, Add, Delete) permission to selected Object
69. What is the need of “Custom Controller” in Visualforce as everything can be done by the combination of Standard Controller + Extension class.
Ans :
·         Sharing setting is applied on standard object/extension by default; In case we don’t want to apply sharing setting in our code then Custom controller is only option.
·         It is possible that the functionality of page does not required any Standard object or may require more than one standard object, then in that case Custom controller is required.

70. In class declaration if we don’t write keyword “with sharing” then it runs in system mode then why keyword “without sharing” is introduced in apex?

Ans:
Lets take example, there is classA declared using “with sharing” and it calls classB method. classB is not declared with any keyword then by default “with sharing” will be applied to that class because originating call is done through classA. To avoid this we have to explicitly define classB with keyword “without sharing”.
With sharing Keyword: This keyword enforces sharing rules that apply to the current user. If absent, code is run under default system context.


Example:
public with sharing class MysharingClass {
// Code will enforce current user’s
// sharing rules
}

Without sharing keyword: Ensures that the sharing rules of the current user are not enforced.
Example:
public without sharing class noSharing {
// Code won’t enforce current user’s
// sharing rules
}

The with sharing keyword allows you to specify that the sharing rules for the current user be taken into consideration for a class.

Some things to note about sharing keywords:
·         The sharing setting of the class where the method is defined is applied, not of the class where the method is called.
·         If a class isn’t declared as either with or without sharing, the current sharing rules remain in effect. This means that the class doesn’t enforce sharing rules except if it acquires sharing rules from another class. For example, if the class is called by another class that has sharing enforced, then sharing is enforced for the called class.
·         Both inner classes and outer classes can be declared as with sharing. The sharing setting applies to all code contained in the class, including initialization code, constructors, and methods.
·         Inner classes do not inherit the sharing setting from their container class.
·         Classes inherit this setting from a parent class when one class extends or implements another.
88. What is analytic Snapshot in salesforce?
Ans : Analytic snapshot capture and store the data at pre decided intervals. It captures data from report and saves in custom object as per schedule. It only supports tabular and summary report as a source report. It does not support matrix report. The field type in target object must be same as source report object field.

97. Will below query work? Explain.

SELECT COUNT(Id), Name, Address__c FROM Opportunity GROUP BY Name

Ans :
Above query will throw an error.
Explanation : In Group by clause the columns selected must be either used in Group by clause or in aggregate functions. The Name field is neither used in aggregate methods and in group by clause and hence will result in error “Malformed Query”.
98. Explain difference in COUNT() and COUNT(fieldname) in SOQL
Ans :
COUNT()
Ø  COUNT() must be the only element in the SELECT list.
Ø  You can use COUNT() with a LIMIT clause.
Ø  You can’t use COUNT() with an ORDER BY clause. Use COUNT(fieldName) instead.
Ø  You can’t use COUNT() with a GROUP BY clause for API version 19.0 and later. Use COUNT(fieldName) instead.

COUNT(fieldName)
Ø  You can use COUNT(fieldName) with an ORDER BY clause.
Ø  You can use COUNT(fieldName) with a GROUP BY clause for API version 19.0 and later.
99. How to write the “Where” clause in SOQL when GroupBy is used ?
Ans : We cannot use the “Where” clause with GroupBy instead we will need to use the “Having Clause“.
Example : Get all the opportunity where more than one record exists with same name and name contains “ABC”.

SELECT COUNT(Id) , Name FROM Opportunity GROUP BY Name  Having COUNT(Id) >  1 AND Name like '%ABC%'

107. Consider total 90k records present in Salesforce and you have used the count() method of soql. What will be output of it?
Ans : It will throw an error something like “Too many query rows: 50001”, as the record limit in SOQL is 50,000.
Although the count() returns only one row however it processes each record and thus hit the allowed governor limit.

108. How can you determine that email is actually sent or not from the salesforce?

Ans:
There is an Email log that you could use. It’s available in the setup menu under Monitoring.
It’s only for the past 30 days and you would have to manually check it.
From the email log page: “Email logs describe all emails sent through salesforce.com and can be used to help identify the status of an email delivery. Email logs are CSV files that provide information such as the email address of each email sender and its recipient, the date and time each email was sent, and any error code associated with each email. Logs are only available for the past 30 days.”

109. In salesforce which fields are indexed automatically?
Ans : 
The following fields are indexed by default:

primary keys (Id, Name and Owner fields),
foreign keys (lookup or master-detail relationship fields),
audit dates (such as LastModifiedDate),
Custom fields marked as External ID or Unique.

110 : Give any scenario when you cannot change the currency field type to numeric


type.
Ans : When the field is used either in Apex class or trigger.

No comments:

Post a Comment