0% found this document useful (0 votes)
12 views80 pages

Interview

The document outlines key concepts related to user management, profiles, and permission sets in Salesforce, including user deletion limitations, granting login access, and security for metadata files. It explains the roles of profiles and permission sets in managing user permissions, as well as various methods for securing records and data access. Additionally, it covers various Salesforce functionalities, triggers, and best practices for writing test classes.

Uploaded by

Harshal Ramdham
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views80 pages

Interview

The document outlines key concepts related to user management, profiles, and permission sets in Salesforce, including user deletion limitations, granting login access, and security for metadata files. It explains the roles of profiles and permission sets in managing user permissions, as well as various methods for securing records and data access. Additionally, it covers various Salesforce functionalities, triggers, and best practices for writing test classes.

Uploaded by

Harshal Ramdham
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Users, Profiles and Permission Sets

Profiles and Permission Sets provides security for meta-data (Structure)


components.
1. Is it possible to delete the user in salesforce?
No, once we create an user in salesforce we cannot delete the user record. We can only deactivate the user record.
2. What is 'Grant Account Login Access'? How to enable 'Grant Account Login
Access'
If we enable 'Grant Account Login Access' for a user then we can see 'Log in' button on the detail page of that user. By
clicking on that 'Log in' button without giving that user's username and password we can log in.
To enable the 'Grant Account Login Access' follow the below steps -
1. Log in as a user to whom you want to enable Log in access.
2. At top right corner click on name (Which should be left to Setup) > My Settings
3. User should be able to see user's personal set up page.
4. Left side, click on Personal Information > Grant Account Login Access
5. User should be able to see Grant Account Login Access page
6. In Access Duration column select '1 Year' for all the records and click on 'Save' button.
7. Log out and Log in as any other user in the organization then click on Manage Users > Users.
8. User should be able to see list of records and verify the user to whom we enabled the Grant Account Login
Access
9. User should be able to see the Login link beside Edit link.
10. Click on Login then user should be able to login as that user mode
11. Observe at top right corner, user should be able to see Logged in as 'Name of the user' which should be
highlighte in black color.
12. Click on Logout
13. User should be come back to original user's mode, Observe at top right corner, user should not be able to see
Logged in as 'Name of the user'
3. How to provide security for Meta-Data files (Schema)?
Using Profiles and Permission Sets.
4. What is Profile?
• Profile deals with CRED (Create, Read, Edit and Delete) permissions over Apps, Tabs, sObjects, Fields,
Record Types, etc...
• We can map only one profile for one user and without mapping the profile we cannot create the user.
5. What is Permission Set?
• To improve the permissions for the users over profiles we should go for Permission Sets.
• Example- To give additional permissions to few users who belongs to different profiles over Apps, Tabs,
sObjects and fields.
6. How to give permissions to two fields for different users who belongs to different
profiles?
Permission sets.
7. How many users are there in your project salesforce instance?
1000 (It will depends upon the number of licenses taken by the client, it will be like upto 4000 like that based on the
client)
8. How to provide security for the Records(Instance)?
1. Roles
2. OWD(Organigation Wide Defaults)
3. Sharing Rules.
4. Manual Sharing
5. Apex Managed sharing
6. View all.
7. Modify all.
8. View all data.
9. Modify all data.
9. What is role?
Role deals with authorization to access data.
10. What is OWD?
OWD is the default access level on records for any object in sales force.
For custom objects we can see below access levels -
1. Private
2. Public Read only
3. Public Read/Write
By default after creating custom object OWD access level is Public Read/Write.

Private: only owner and above hierarchy users can have Read/Write access and below hierarchy users don't have any
access.
Public Read only: only owner and above hierarchy users can have Read/Write access and below hierarchy users can
have only Read Only.
Public Read/Write: Irrespective of role hierarchy every one can have Read/Write permissions on the records.
11. What is Grant Access Using Hierarchies?
Say there are three roles
• Role A
• Role B
• Role C
Role A is higher in hierarchy, Role B is in middle and Role C is lower in hierarchy
If the Role A user through Manual Sharing or Sharing Rules, shares the record to Role C user who is in lower hierarchy,
then the Role B user who is above in hierarchy to Role C user can see the records, if we enable Grant Access Using
Hierarchies at sharing settings else Role B user cannot see the record.

1. Tell me about ur project?

2. what u used in background in ur project customization or configuration?

3. if we talk about customization what features do you know?

4. if i m going to be create trigger on contact record and whenever is having email it should update
account email? what u will used?

and in update case? (After insert/after trigger)

5. whenevr contact is inserterd or updated there is one check box email is having check box its
true and if not its false?

what functionality u will used? what event u will used before update or after update? why ur
going to used it?

6. opproutinity and oppoyrtuinty line item , whenevr i insert opprouytunity line item is having
price not equal to zero

or something else u have to prepare discount with 10% and oppourtunity also having the same
amount?how u will achieve this using
trigger?which fielld u will update in which event?

7. what is dirffrence between after event and before event? what we can do in before insert that
we cant do in after insert?

8. if i m inserting one record what i can do in before insert and what i can’t do in after insert?

9. can we apply validation in after trigger?

10. i want to populate custom filed on same record using trigger what event u will used before or
after? why?

11. i have one visualforce page and there is one controller and two extensions ex1 and ex2 and a
method which is calling from vf page i.e. methodcall() ,

methodcall() is available in controller, ex1 and ex2 [Link] method will call on vf page?

12. we have vf page with binding of list of objects so how many records we can show vf page with
list object ?how many records we can iteatre? and if i want to iterate

more than 1000 records? query locator directly accessble on vf page?

13. why we used batch apex instead of controller?

14. which type of task we can do with workflow?

15. what will be the best for field update, trigger or workflow? workflow will support bulkificaion
or not?

16. whatt is diffrence between SOSL & SOQL?


[Link] many record i can update in single dml statement?

18. we have trigger we are calling class method , class is having with sharing, whenever record is
craeted bt it is not having permission to related child record so it

should create child record or not, while creating contact record?

19. and same condition without sharing?

20. trigger is running in user context or system context?

21. suppose i have list in that 200 records and 10 records are going to failed so if i want to insert
remianing record what u will used?

22. what about profile and persmission set?

23. we have one profile and persmission set, with persmission we grant some persmission,now
clients want to

revoke the permission , from where u will revoke it?

24. there is one custom object abc , abc having validation rule ;like male should not be null, then
trigger that also having validation rule female

should not be null,then there is workflow ie updating field workflow also sented the email?so
when workflow will email sent? trigger will get execute it or not?

at what time email will sent at what event?

25. i m having two validation rule standard and custom whhich will execute first?

Cloudcertitude:----
[Link] me about ur self

[Link] projects

[Link] in projects

[Link] id internal id

[Link] there is id in url so how can i get that id

[Link] is trigger

[Link] variable

[Link] are events

[Link] practice to write test class

[Link] is seealldata = true

[Link] difference between them

[Link] function,action support

[Link] builder n workflow

[Link] in sfdc n diff bet role n profile

[Link] set

[Link] insert bet [Link]

[Link] is difference between [Link](list,false) n [Link](list,true)

[Link] is workflow

Absyz:----

[Link] me about ur self

[Link] projects

[Link] in projects

[Link] u work on lightning

[Link] many way to update record


[Link] is workflow what are evolution criteria diff bew create and edited every time and created
and any time its edited to subsequently meets criteria

[Link] u worked on process builder

[Link]

[Link] are data types in sfdc

[Link] i want to make field mandetory so how can i do this n what are diferent ways

[Link] setting

[Link] state

[Link] is trigger

[Link] which case u going to use before trigger

[Link] why we do not need to perform dml operation in before trigger.

[Link] bet process buider and workflow

[Link] practice for trigger

[Link] of execution

[Link] why we use batches.

[Link] is future method

[Link] practice for writing test class

[Link] n permission set n difference between them

[Link] is dynamic binding (Detail)

[Link] between custom controller and extension

[Link] is wrapper class.

Absys 2nd round:-

[Link]

[Link] type of work u do

[Link] ur self

[Link] type of role in ur project

[Link] u did in ur project


[Link]

[Link]

[Link] hierarchi works in role

[Link] me any situation

[Link] rule who can share the record

[Link] salesperson who reports to sales manager so in dis situation can sales manager share
[Link] sharing rule.

[Link] object-level permissions conflict with record-level permissions, then what will happen

[Link] n outbound msg

14.i hv workflow use 2nd evolution if record name start with P then it ll send mail or [Link]
what will hapen if name start with T then what [Link] i agin change it to P than mail will send or
not. Why in 2nd criteria we can not create time dependent [Link] i want to send in future so
what can i do.

deloitt:---

[Link] me about ur self

[Link] urself

[Link] between lookup and master [Link] me scenario whe i should go for master or lookup
n why

[Link] roll up summery. can we have average.

[Link] for makeing field [Link] are the ways make field madetory

[Link] writing workflow rule what are evolution [Link] i go for which perticulor criteria.

[Link] is two field first is pick list field on the basis of value of picklist i want to update one field is it
possible.

[Link] is two object account and opportunity if i crete record on account on that basis i want to
crate opportunity record is it possible.

9.I have not given any CRUD permission in the profile 'P1' for an object O1, yet I'm able to create
records for object 'O1'. How could this be possible

10.I have two un related objects Obj1 and Obj2. Now I want to create a Master Detail relation
between these objects how do I do this?

[Link] there are pre existing records in the Obj2 then With the above understanding on Master Detail
relation we have to be sure that every record in Obj2 has a related record in Obj1. And in our
scenario Obj1 and Obj2 are not related to each other. So first we have to create a basic Look up
relation between these two objects so that we can establish a relation between these two objects

12.i have picklist field which used in 3 differnt objects how can i do this.

[Link] user perform updation then i want to post chatter how can we do this

[Link] is two object account and opportunity if i crete record on account on that basis i want to
crate opportunity record how can we do this using trigger

[Link] of execution

16.i have field proficiency which show images if proficiency excellent than show green image if
proficiency is bad then show red image how can i do this using point click functionality

17.i have vf page on which display time i want to refresh that portion after each 10 second how can i
do this

18.i have vf page i have form if user enter wrong data i want to display error msg if all values are
appropriate the save record into the database

19.i have vf page which i want to sent as mail when workflow aries so how can i do this

[Link] have standard page called opportunity i want to override it with custom functionality how can
i do this

21.i want to create vf page i want input box in which i want to enter name after click on search
button the records having that name should be visible to [Link] i enter vipeen then show me the
record whos name is vipeen

[Link] practice for writing test class

23.i want run test for particular user how can i do this.

[Link] i use seealldata=true n deploy into production so how it effect to system.

[Link] is future method

[Link] is batch.

27.i have batch which update for particular time what are detail step to perform if
Technomile-

[Link]

[Link] how u get the requirement

[Link] experience

[Link] u learn salesforce

[Link]

7. What kind of programing u do

[Link] are [Link] bet extension and custom [Link] and

9. Can we perform dml in [Link] have requirement like that so what we can do.

[Link] we update [Link] are way.

[Link] bet process builder and trigger

[Link] bet set and map

[Link] method of maps.

[Link] we perform dml operation on [Link] we perform dml operation on [Link] we perform dml
operation on map.

[Link] limit

[Link] event of trigger in [Link] ,[Link].

[Link] dml [Link] we prevent or manage it.

[Link] to write test class for trigger.

[Link] u display error msg

[Link] is apex check box

[Link] is bach class.

[Link] u work on lightning

[Link] which case we ha for future method.

[Link] i need to write test class for future method ,how u achieve this
[Link] is [Link] is data [Link] how integration and data migration is different from
each other.

Deloitte Interview Questions

Technical Round-1 and Round-2

1. Describe OFFSET and give example and why we use?


Ans- OFFSET is a clause which is used in SOQL query. When using offset only first batch of records
are returned for a given query. If you want to retrieve next batch you will need to re-execute query
with the highest OFFSET Value.

Example- A query like- [select id, name from Account limit 10 OFFSET 10]

Then it will return record from 11 to 20.

2. Can we convert lookup in to master-detail relationship and how?

Ans- Yes , we can convert lookup to master but When we are converting lookup in to master then any
of the lookup fields should not be blank, if there will be blank then populate values in lookup fields
then covert.

3. How to find that which record is inserted/ updated in batch class?

Ans- Use SaveResult class like [Link][] srLst=d [Link](lstData, false); and
there is isSuccess() method which finds the successfully record inserted and getError() method used
to get error from the failure record and by using getId() method we can get failure records Id in class.

4. How to find that which record is inserted/ updated in batch class?

5. How to use rest Api in class?


6. What is custom metadata and how do we use custom metadata?

Ans- Follow this link-- [Link]


[Link]

7. What is difference between profile and permission set?

Ans- The difference between Profile and Permission Sets is Profiles are used to restrict from
something where Permission Set allows user to get extra permissions.

Lets take Example--

You have one profile assigned to 15 different users.

Now Suppose you want give some extra permission to one of user. You have two options here.

a) To change Profile permissions : By this way those extra permissions will received by every user
who is having that profile

b) Second way is to create a permission set having those extra permission. You need to assign this
permission set to particular user by navigating to User detail page. In this way, you dont have to
worry about other users, as only specific user is getting those extra permissions.

You can assign permission set as many users you want.

8. If profile has read access and we create permission set with read/write access then what will
happen?

Ans- Then profile will have both read and write access.

9. If profile has read/write and permission set has read access then what will happen?

Ans- Then profile will have both read and write access. We cannot decrease permission onprofile but
we can increase permissions using permission set.
10. If account has related list Address and there is checkbox name primary, then record insert in
Address then each account has only one address with checkbox true if records exist already in
address with checkbox true then make them false.

11. What is future method?

Ans- Follow this link-- [Link]


[Link]

12. Why we use future method and provide scenario where you have used future method?

Ans- Follow this link-- [Link]


[Link]

13. How to read JSON in your class?

14. Do you know about SOAP and Rest API?

15. What is difference between role and profile?

Ans- Role determines what is visible to the user

Profile determines what actions they are allowed to perform

16. Can we create user without profile?

Ans- NO

17. What is difference between insert and [Link]()?

Ans- Follow this link: [Link]


[Link]
18. Why we use true and false in [Link]()?

Ans- Follow this link: [Link]


[Link]

19. If we have list of integer type and there is 20 items and want to display list in table on page and I
want to display 5 data then 5 and then 4 so on, how you will display?

20. If we have 10 data and inserting 10 data and 3 insert successfully and failed at 4 then what will
happen when using [Link]() .

Ans- It will insert success records and not insert error records.

21. Can we change picklist data type into text?

Ans- Yes

22. How to get list of child data in email templates.

Ans- Cross Object Email Template is not Possible in salesforce at this point in time Only Possible way
to access and Display child record details in email template of parent is to use Visualforce Email
Templates.

23. If there is one object and we create two lookup field related to User object. And we have 3 users
like A, B, C of same roles and same profile. If we have assigned two users in two lookup like A and
B then only these two user can edit that object record C user cannot be able to edit the record.
How will you achieve this?

24. What is having clause? Give the example.

Ans- HAVING is a clause that can be used in a SOQL query to filter results that aggregate functions
return. You can use HAVING clause with GROUP By clause to filter the results returned by aggregate
function,such as SUM(). HAVING clause similar to WHERE clause. The difference is that you can
include in aggregate functions in a HAVING Clause , but not in WHERE Clause.

Ex- Firstly query,

[Select Id, name from Lead] → It will return Lead record with Id and Name.

[Select Id, Name from Lead GROUP BY name] then it will through error like Field must be grouped or
aggregated: Id

[Select id, count(name) from Lead GROUP BY name ]-- then it will also through error , you cannot use
same field name used in count i.e-- select id, count(name) from Lead GROUP BY name ^ ERROR at
Row:1:Column:18 Grouped field should not be aggregated: Name

[SELECT LeadSource, count(Name) FROM Lead GROUP BY LeadSource]-- Now it will return record
With LeadSource and count total name field correspond to particular LeadSource.

[SELECT LeadSource, count(Name) FROM Lead GROUP BY LeadSource HAVING count(Name)>6]-- It


will filter above group by query and return records which count is greate than 6.

25. What is return type of SOSL query?

Ans- List<List<SObject>>

26. What is return type of Aggregation query?

Ans- AggregateResult[]

27. What is soft delete and hard delete?


Ans- Using Hard Delete your data will not be stored in the recycle bin. It will be
permanently deleted.

But using Soft Delete you can restore those datas lated within 15days from recycle bin.

28. Difference between with sharing and without sharing?

Ans- "with sharing" keyword in apex class so that it will enforce only sharing rules of current user but
not, object permissions, field level permissions

But “without sharing” will not enforce only sharing rules of current user . does it mean it will enforce
current user object and field level permissions.

29. Can we show error message using future method?

Cognizant Interview Questions

Technical Round-1 and Round-2

1. Difference between all evaluations criteria in workflow rules?


Ans-
Evaluate the rule criteria each time a record is created. If the rule criteria
is met.

Created In this option, the rule never runs more than once per record.

Evaluate the rule criteria each time a record is created or updated. If the
rule criteria is met, run the rule.

In this option, the rule repeatedly runs every time a record is edited, as
long as the record meets the rule criteria.

created, and every time Note: We cannot add time-dependent actions to the rule if you select
it’s edited this option.

Evaluate the rule criteria each time a record is created or updated.


created, and any time i
For a new record, run the rule if the rule criteria is met.

For an updated record, run the rule only if the record is changed from

not meeting the rule criteria to meeting the rule criteria.
t’s edited to subsequently With this option, the rule can run multiple times per record, but it won’t
meet criteria run when the record edits are unrelated to the rule criteria.

2. We have two team service team and sales team, and we have 15 fields in Account
object and want to show 10 fields to service team and 5 fields to sales team,
how will you do this?

3. Define all sharing rules?

4. What is Re-evaluate checkbox in workflow?

5. What is trigger framework?

6. What is process builder? Can we use apex class in process builder?


7. Difference between process builder and workflow?

8. What is upsert? How it works?

9. Can we call future method in batch class?

Capgemini Interview Questions

Technical Round-1 and Round-2

b 1. What are Salesforce securities?

2. I want to delete child when I delete parent object records in lookup relationship, because we
have already too many master-detail in object and not able to create master-detail, so how will
you do this task?

3. We have table with two rows with two columns, and data in table as-

Columns: Name class

Rows : Arun 10

Aman 12
Write query to count of total number of 12th class student.

4. How to write rollup summary for lookup and how to update roll up summary using lookup.

5. Write down Roll Up summary trigger.

6. What are the mixed DML operations?

Ans:- Follow link-- [Link]


[Link]

7. What are the best practices for test class?

8. What are the AJAX functions in salesforce?

9. Difference between render, rerender, render as.

10. What are the Sharing rules?

11. What is OWD? If for any object OWD is private so what will happen?
12. What is the default OWD of tasks and events?

Ans:- In [Link], for Activity objects (Task & Event), there are only 2 option in the Organization-Wide
Defaults sharing setting:

- Controlled by Parent
- Private

Private
Only activity owner (label as Assigned To), and users above the activity owner in the role hierarchy can edit
and delete the activity.
Users with read access to the record to which the activity is associated (Name and Related To) can view and
report on the activity.

Controlled by Parent
A user can perform an action (such as view, edit, transfer, and delete) on an activity based on whether he or
she can perform that same action on the records associated with the activity.

Example, if a task is associated with the Acme account and John Smith contact, then a user can only edit that
task if he or she can also edit the Acme account and the John Smith record.

13. Difference between save report and run report?

14. What are the buckets and formula fields in reports?

15. What is future method? What are the restriction of the future method? Can we call future
method from batch class?

16. Write query to get child from parent.

17. Assume there is user lookup in Account, if any user create account record then that user Id
should populate in lookup, how will you do this task?

18. Can we update record on account on ‘After insert’ trigger event?


19. What is forecasting in Salesforce?

20. What is territorial management?

21. What are the types of trigger and events?

Ans-
There are two types of triggers:

Before triggers are used to update or validate record values before they’re saved to the database.

After triggers are used to access field values that are set by the system (such as a record's Id or
LastModifiedDate field).

Trigger Events:

Before Insert, Before Update, Before Delete, After Insert, After Update, After Delete and
after undelete

22. What is workflow and time dependent workflow? Write will send mail after 15 mins?

23. Create visual force page1 with 3 rows data like Here no data from database, just you
create your own field
Column: Name Checkbox
Row 1: Arun True
Row 2: B False
Row 3: C True

Now we have showData button, then on click on button data which has checkbox
True should display on another visual force page.
6 comments:
1.

Anonymous22 September 2017 at 00:08

great brother..please provide answers


Reply

Replies

1.

arun garg4 October 2017 at 15:25

Now find your answers here , I provide answers of some questions.


Reply

2.

Muthu Vignehswaran13 November 2017 at 10:09

Hi Arun,

Can provide more interview questions for Deloitte interview?


Reply

Replies

1.

arun garg22 November 2017 at 11:18

Hi , I have posted questions here .. some are left so I will provide rest.
Reply

3.

Unknown17 December 2017 at 11:37

what will be the answer of below

1) If we have list of integer type and there is 20 items and want to display list in table
on page and I want to display 5 data then 5 and then 4 so on, how you will display?
2) If account has related list Address and there is checkbox name primary, then
record insert in Address then each account has only one address with checkbox true
if records exist already in address with checkbox true then make them false.
3) If there is one object and we create two lookup field related to User object. And we
have 3 users like A, B, C of same roles and same profile. If we have assigned two
users in two lookup like A and B then only these two user can edit that object record
C user cannot be able to edit the record. How will you achieve this?
4) Can we show error message using future method? How?
5) We have two team service team and sales team, and we have 15 fields in Account
object and want to show 10 fields to service team and 5 fields to sales team, how will
you do this?
6) Define all sharing rules?
7) What is Re-evaluate checkbox in workflow?
8) What is trigger framework?
9) What is process builder? Can we use apex class in process builder?
10) Can we call future method in batch class?
11) How to write rollup summary for lookup and how to update roll up summary using
lookup.
12) Write down Roll Up summary trigger.
13) What are the AJAX functions in salesforce?
14) Difference between render, rerender, render as.
15) Difference between save report and run report?
16) What are the buckets and formula fields in reports?
17) What is future method? What are the restriction of the future method? Can we call
future method from batch class?
18) Write query to get child from parent.
19) Assume there is user lookup in Account, if any user create account record then
that user Id should populate in lookup, how will you do this task?
20) Can we update record on account on ‘After insert’ trigger event?
21) What is forecasting in Salesforce?
22) What is territorial management?
23) What are the types of trigger and events?

1. Is it possible to write a validation rule which will fire only on insert of record
not on update of record ?

Answer: Use isnew() function which checks if the formula is running during the
creation of a new record and returns TRUE if it is. If an existing record is being
updated, this function returns FALSE.

2. Is it possible to schedule a dynamic dashboard in Salesforce?

Answer: No, it is not possible to schedule a dynamic dashboard in Salesforce.

3. Is it possible to write a validation rule on record delete?

Answer: No, only in insert and update events you can write validation rule.
4. Difference between formula field and rollup summary in Salesforce ?

Answer: Rollup Summary field is used to calculate the sum of a fields in the child
object record. It is compulsory to be in a Master-Detail relationship to use the
rollup summary. A rollup summary field is always created on Master record.
(Parent to Child).

For example. You have an Account and multiple Contacts under that Account.
Each of the Contact have a number field on it say Contacted People. Now on the
Account you can create a Rollup summary to check the Number of Contacted
People via all your contacts.

Where else a formula field is mostly used for calculations within a certain object.
And it is child to Parent.

5. Is there any standard object which is also act as junction object ?

Answer: Yes there are some standard objects which acts as a junction object.

For Example, Standard object OpportunityContactRole is acts as junction object


between Opportunity and Contact objects.

6. What is the default data time format of Salesforce ?

Answer:

DateTime: Salesforce stores all DateTimes in Coordinated Universal Time (UTC)


format. Remember that dateTime field values are stored as Coordinated
Universal Time (UTC). When one of these values is returned in the Salesforce
application, it is automatically adjusted for the timezone specified in your
organisation preferences. Your application may need to handle this conversion.

Date : fields contain no time information and completely ignore timezones.


Whatever date you specify when you set it will be the date every user sees, with
any time and zone information being ignored.

7. How to insert null values into Dataloader ?

Answer: Go to data loader -> setting -> check Is null values checkbox.

8. Maximum batch size of data loader?

Answer: 200

9. What is the purpose or use of @TestVisible?


Answer: Use the TestVisible annotation to allow test methods to access private
or protected members of another class outside the test class. These members
include methods, member variables, and inner classes.

Using this annotation, you don not have to change the access modifiers of your
methods and member variables to public if you want to access them in a test
method.

For example, if a private member variable isn’t supposed to be exposed to


external classes but it should be accessible by a test method, you can add the
TestVisible annotation to the variable definition.

10. What is the difference between trigger and workflow in Salesforce ?

Answer:

Workflow:

1. Workflow will be helpful to update the same object or master object in


custom master-detail relationships.
2. Coding is not required.
3. Workflow actions are Field Update, Email alert, Task alert and outbound
message.
4. We cannot use SOQL query from database on workflow.
5. We cannot fire workflows after record has been deleted.

Trigger:

1. Trigger can work across objects.


2. Coding is required.
3. Trigger executes before or after these types of operations insert, update,
delete, merge, upsert & undelete.
4. We can use SOQL’s from data base in one trigger.
5. We can fire Trigger after record has been deleted.

11. What is fiscal year in salesforce ?

Answer: If your organisation fiscal year follows the Gregorian calendar, but does
not start in January, you can simply and easily set your fiscal year by defining a
standard fiscal year with a different starting month. If your fiscal year follows a
different structure from the Gregorian calendar, you can define a custom fiscal
year that meets your needs.

Whether you use a standard fiscal year or a custom fiscal year, you define
individual fiscal years one time. These fiscal year definitions allow you to use
these fiscal periods throughout Salesforce including in reporting, opportunities,
and forecasting.
Salesforce allows two types:

–Standard Fiscal Years are periods that follow the Gregorian calendar, but can
start on the first day of any month of the year. (A Gregorian Year is a calendar
based on a 12 Month Structure and is used throughout much of the world.)

–Custom Fiscal Years are for companies that break down their fiscal years,
quarters and weeks in to custom fiscal periods based on their financial planning
requirements.

Note: After you enable custom fiscal years, you cannot disable the feature.
However, if you need to revert to standard fiscal years, you can define custom
fiscal years that follow the same Gregorian calendar structure as the Salesforce
standard fiscal years.

12. What is the difference between Role and Profile in Salesforce ?

Answer:

Role control record level access can be controlled by Role.

Profiles control the objects level access settings.

In simple words, Profile defines what user can do in your salesforce org and Role
defines what user can see.

Other difference is, Profile is mandatory, Role is not.

13. Will data be lost in a custom field if data type is changed to number from any
other data type?

Answer: Yes

Changing the data type of an existing custom field can cause data loss in the
following situations:

 Changing to or from type Date or Date/Time


 Changing to Number from any other type
 Changing to Percent from any other type
 Changing to Currency from any other type
 Changing from Checkbox to any other type
 Changing from Picklist (Multi-Select) to any other type
 Changing to Picklist (Multi-Select) from any other type. Currently defined
picklist values are retained when you change a picklist to a multi-select picklist.
If records contain values that are not in the picklist definition, those values are
deleted from those records when the data type changes.
 Changing from Auto Number to any other type
 Changing to Auto Number from any type except Text
 Changing from Text to Picklist
 Changing from Text Area (Long) to any type except Email, Phone, Text,
Text Area, or URL.

14. There is one field which is used in Lead conversion and I want to convert its
data type, is this possible?

Answer: No, You can not change the data type of any custom field that is
mapped for lead conversion.

15. Can we convert formula field into any other data type ?

Answer: No, Formula fields are special read-only fields that cannot be converted
to any other data type. Likewise, you cannot convert any other field type into a
formula field.

16. What is Web-to-Lead in Salesforce ?

Answer: In simple words, Web-to-Lead is Generate Leads from Your Website for
Your Sales Teams. This feature create or generate upto 500 leads per day with
prospecting data from your company’s website visitors.

Salesforce runs field validation rules before creating records submitted via Web-
to-Lead and only creates records that have valid values.

If a new lead cannot be generated due to errors in your Web-to-Lead setup,


Customer Support is notified of the problem so that we can help you correct it.

17. What is the Web-to-Case in Salesforce?

Answer: In simple word, Capture Cases from your Website.

Gather customer support requests directly from your company’s website and
automatically generate up to 5,000 new cases a day with Web-to-Case. This can
help your organisation respond to customers faster, improving your support
team’s productivity.

Use a simple web form or a self-service customer community to make it easy for
customers to submit cases directly to your customer support group.

Keep these considerations in mind:

 Whenever possible, Web-generated cases are automatically linked to the


relevant contact and account based on the customer’s email address.
 Salesforce runs field validation rules before creating records submitted via
Web-to-Case and only creates records that have valid values. All universally
required fields must have a value before a record can be created via Web-to-
Case.
 Salesforce doesn’t support rich text area (RTA) fields on Web-to-Case
forms.
 If you exceeded the daily limit and you want to increase that limit then go
to Help & Training and raise a case with salesforce.

18. What are the Types of Sharing Rules in Salesforce and explain it?

Answer:

Account Sharing Rules:

– Based on who owns the account

– Set default sharing access for accounts and their associated cases,
contacts, contracts, and opportunities

Contact Sharing Rules:

– Based on who owns the contact (must be associated with an account)

– Set default sharing access for individual contacts and their associated
accounts

– Cannot use with: Territory Management and B2I (Person Account)


enabled orgs

Opportunity Sharing Rules (EE/UE):

– Based on who owns the opportunity

– Set default sharing access for individual opportunities and their


associated accounts

Case Sharing Rules (EE/UE):

– Based on who owns the case

– Set default sharing access for individual cases and associated accounts

Lead Sharing Rules (EE/UE):

– Based on who owns the lead

– Set default sharing access for individual leads

Custom Object Sharing Rules (EE/UE):

– Based on who owns the custom object

– Set default sharing access for individual custom object records

19. How many rows return by list controller?

Answer: 10000 records


20. How can we check the object accessibility on visualforce page?

Answer: {!$ObjectType.MyCustomObject__c.accessible}

21. What are the different AJAX action tags? What does each do?

Answer:

actionStatus: used to display start and stop statuses of AJAX requests.

actionSupport: used to call a second component when an event happens to the


first component.

actionPoller: similar to actionSupport, but the event is based on a timer instead


of a user action.

actionFunction: provides support for invoking a controller action from


JavaScript code using an AJAXrequest by defining a new JavaScript function.

actionRegion: used to demarcate which parts of the page the server should
reprocess.

22. How many ways call controller from visualforce page ?

Answer:

Commandbuton, commandlink, Javascript remoting, actionpoller, actionFunction.

23. What is the size of view state in salesforce ?

Answer: 135 KB

24. Does Javascript remoting is part of view state ?

Answer: NO

25. I want to count how many times execute method executed in Batch class ?

Answer: With the help of [Link]

26. Compare JavaScript Remoting and <apex:actionFunction> ?

Answer: The <apex:actionFunction> component also lets you call controller


action methods through JavaScript.

In general, <apex:actionFunction> is easier to use and requires less code, while


JavaScript remoting offers more flexibility.
Here are some specific differences between the two :

The <apex:actionFunction> tag:

 lets you specify rerender targets


 submits the form
 doesn’t require you to write any JavaScript
JavaScript remoting:

 lets you pass parameters


 provides a callback
 requires you to write some JavaScript
27. Difference between count() and count(fieldname) ?

Answer: For COUNT(), the query result size field returns the number of rows. The
records field returns null.

COUNT(fieldName) returns the number of rows that match the filtering conditions
and have a non-null value for fieldName.

28. What are the Best Practises for Improving Visualforce Performance ?

Answer:

1) The view state size of your Visualforce pages must be under 135 KB. By
reducing your view state size, your pages can load quicker and stall less often.

2) Large page sizes directly affects load times. To improve Visualforce page load
times:

 Cache any data that is frequently accessed, such as icon graphics.

 Avoid SOQL queries in your Apex controller getter methods.

 Reduce the number of records displayed on a page by adding filter condition in


SOQL

3) Reduce Multiple Concurrent Requests: use <apex:actionpoller>

4) By using the with sharing keyword when creating your Apex controllers, you
have the possibility of improving your SOQL queries by only viewing a data
set for a single user.

5) Preventing Field Values from Dropping Off the Page.

29. What are the Salesforce best practices for apex?

Answer:

 Bulkify your Code


 Avoid SOQL Queries or DML statements inside FOR Loops
 Bulkify your Helper Methods
 Using Collections, Streamlining Queries, and Efficient For Loops
 Streamlining Multiple Triggers on the Same Object
 Querying Large Data Sets
 Use of the Limits Apex Methods to Avoid Hitting Governor Limits
 Use @future Appropriately
 Writing Test Methods to Verify Large Datasets
 Avoid Hardcoding IDs.

30. What is the difference between [Link] and [Link]?

Answer:

[Link] is Platform as a Service (PaaS)

[Link] is Software as a Service (SaaS)

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.

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.
See more: 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.

37. What are the Different API's in salesforce ?


Answer :
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.

REST API :
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.

BULK API :
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 :
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 :
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?
Answer:
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 [Link] and insert?

Answer :

Both DML statements perform same operation i.e. insert records.

Insert is the DML statement which is same as [Link].

However, [Link] gives more flexibility like rollback, default assignment


rules etc. we can achieve the [Link] behavior in insert by using the
method setOptions([Link]).

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 ([Link]) 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?
Answer:
15 digit ID in [Link] 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 [Link] 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.

[Link] has recognized this problem and [Link] 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?


Answer:
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?


Answer:
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 [Link]() ?


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,
[Link](), 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 :
[Link](u) {
// The following code runs as user 'nitish'
[Link]('Current User: ' + [Link]());
[Link]('Current Profile: ' + [Link]());
}
// 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 [Link]() ?


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.

51. What is the difference between apex:dataTable and apex:pageBlockTable


components in Visualforce?
Answer : Both component is used to render data in tabular format.
apex:dataTable will render records in simple HTML table format whereas the
apex:pageBlockTable possess default look and feel of salesforce standard CSS
and must be written inside apex:pageBlock component.

52. How to get all records even from recycle bin or Achieved Activities using
SOQL query?
Answer : We will need ALL Rows clause of SOQL.
Example :
SELECT COUNT() FROM Opportunity WHERE AccountId = [Link] ALL ROWS

53. How can you lock record using SOQL so that it cannot be modified by other
user.
Answer : We will need FOR UPDATE clause of SOQL.
Example :
SELECT Id FROM Contact LIMIT 2 FOR UPDATE

54. In trigger, lets say you have [Link]() statement after adderror()
method. Will [Link]() be statement executed in Trigger after adderror()
method?
Answer: adderror() method is not error statement rather its normal execution
flow and all the statements written after adderror() will be executed normally.

55. How to get total number of Child records in Lookup relationship?


Answer: As Rollup Summary field is only supported in Master detail, we cannot
use it for Lookup.
There are following two ways.

1. Inline Visualforce page


2. Trigger on Child Object, which will update field in Parent record if child record
is inserted, deleted or undeleted.
If anyone has any other idea please comment. I will add that too.

56. What will happen if you try to update record in After Trigger Context?
Answer : You will get an error saying record is Read only.

How to get IP Address of User in Apex?


Answer : String ipAddress = [Link]().getHeaders().get('X-
Salesforce-SIP');

X-Salesforce-SIP has the value if there is no caching integration (sandbox,


developer edition orgs) or via the secure URL.

57. We have a Time Based Workflow and there is Action scheduled to be


executed. If we Deactivate the workflow, Scheduled actions will be removed from
queue or not?
Answer : Even after deactivation of workflow, its action will be active in queue.

58. How to clear the Time based workflow action queue ?


Answer : Two ways to achieve this.

 Make criteria false for all those records.


 Go to Set up -> Monitoring -> Time Based Workflow and search for
scheduled actions and then remove from queue.
59. We have Time Based Workflow and there is action scheduled to be executed.
Can we delete that workflow?

Answer : If a workflow have any pending time dependent action, then we cannot
delete the workflow.

60. While creating workflow on Task object, what difference observed on


available actions?

Answer : Send Email action is not available while creating workflow on task
object.

61. Explain few considerations for @Future annotation in Apex.


Answer :
Remember that any method using the future annotation requires special
consideration because the method does not necessarily execute in the same
order it is called.

 Methods with the future annotation cannot be used in Visualforce


controllers in either getMethodName or setMethodName methods, nor in the
constructor.
 You cannot call a method annotated with future from a method that also
has the future annotation. Nor can you call a trigger from an annotated method
that calls another annotated method.
 Method must be static
 Cannot return anything i.e. ( Only Void )
 Parameter to @future method can only be primitive or collection of
primitive data type.
 To test @future methods, you should use startTest and stopTest to make it
synchronous inside Test class.
62. How you can use Datetime field as a criteria in SOQL Query ?
Answer :
We cannot use Datetime as condition in Where Clause in between single Quotes.
You can do something like this ,
WHERE CreatedDate > 2017-01-02T00:00:00Z
OR you can also use Date Literals like
WHERE CreatedDate > YESTERDAY

63. Why I am not able to find list of Person Account fields in Field Level Security
(FLS) settings when navigated to fields on Account Object.
Answer :

Field Level Security (FLS) of Person Account fields are controlled by Contact
Fields. So, if you want to setup FLS of Person Account Fields navigate to fields of
Contact and it will be reflected on Person Account.

64. Explain functionality of [Link] Query Optimizer.


Answer :
The [Link] query optimizer:

 Determines the best index from which to drive the query, if possible,
based on filters in the query
 Determines the best table to drive the query from if no good index is
available
 Determines how to order the remaining tables to minimize cost
 Injects custom foreign key value tables as needed to create efficient join
paths
 Influences the execution plan for the remaining joins, including sharing
joins, to minimize database input/output (I/O)
 Updates statistics

[Link] to report on User License field?


Answer :
Create formula field in User Object with formula [Link].
Note: You need to copy and paste this value because it doesn’t show up in the
fields drop down.

66. Explain Skinny table in Salesforce.


Answer :
Salesforce creates skinny tables to contain frequently used fields and to avoid
joins, and it keeps the skinny tables in sync with their source tables when the
source tables are modified. To enable skinny tables, contact [Link]
Customer Support.
For each object table, Salesforce maintains other, separate tables at the
database level for standard and custom fields. This separation ordinarily
necessitates a join when a query contains both kinds of fields. A skinny table
contains both kinds of fields and does not include soft-deleted records.

67. What are the considerations for Skinny Table?


Answer :

 Skinny tables can contain a maximum of 100 columns.


 Skinny tables cannot contain fields from other objects.
 Skinny tables are not copied to sandbox organizations. To have production
skinny tables activated in a sandbox organization, contact [Link]
Customer Support.

68. How to capture errors after using Database DML methods in Salesforce?
Answer :
List<Contact> lstContact = new List<Contact>();
Contact con = new Contact (lastName = 'Talekar',
SQL_Server_Id__c='3',firstName='Nitish');
[Link](con);
// add some other contacts records in contact List
[Link][] results = [Link]( lstContact,
Contact.SQL_Server_Id__c.getDescribe().getSObjectField() ,false ) ;

for(Integer i=0;i<[Link]();i++){
if (![Link](i).isSuccess()){
[Link] err = [Link](i).getErrors().get(0);
[Link]('Error - '+[Link]() + '\nStatus Code :
'+[Link]()+'\n Fields : '+[Link]());
}
}

69. Which fields are automatically Indexed in Salesforce ?


Answer :

 RecordTypeId
 Division
 CreatedDate
 Systemmodstamp (LastModifiedDate)
 Name
 Email (for contacts and leads)
 Foreign key relationships (lookups and master-detail)
 The unique Salesforce record ID, which is the primary key for each object.

70. Which fields cannot be added as a custom Index?


Answer :

 multi-select picklist
 text area (long)
 text area (rich)
 non-deterministic formula fields (Like any formula field using function
NOW() or Today() )
 encrypted text fields.

71. What is best practice to refer dynamic custom messages in Visualforce with
multi-language support ?
Answer :
Using Custom Label or OutputField or InputField tag, Platform itself will take care
of internationalization. However in some cases, Message needs to be dynamic at
the same time it should also support muti-language. In Custom Label, we cannot
save dynamic String.
Let’s assume we want to show message something like “DEVELOPERNAME is not
authorized to access this page”.
Here, Developername should be dynamically changed in visualforce which
supports multilanguage. For each developername, it is not feasible to create
custom labels. So below workaround can be used :

Step 1 : Create a Custom Label with text {0} is not authorized to access
this page. In every language, dynamic value should represented by {0}.

Step 2 : In Controller of Visualforce write something like this :

String developerName = 'Some Developer Name';


String message = [Link]([Link] , new String[]
{ developerName });

72. What are the tools included in lightning ?


Answer :

Lightning Component Framework – Components and extensions that allow you to


build reusable components, customise the Salesforce1 Mobile App, and build
standalone apps.
Lightning App Builder – A new UI tool that lets you build apps lightning fast, using
components provided by Salesforce and platform developers.
Lightning Connect – An integration tool that makes it easier for your [Link]
app to consume data from any external source that conforms to the OData spec.
Lightning Process Builder – A UI tool for visualizing and creating automated
business processes.
Lightning Schema Builder – A UI tool for viewing and creating objects, fields, and
relationships.

73. Difference between Chatter API and Connect API in Salesforce.


Answer :

Chatter API is REST API for Chatter to display Salesforce data, especially in
mobile applications. Responses are localized, structured for presentation, and
can be filtered to contain only what the app needs.
Connect API provides apex classes for accessing the same data available in
Chatter REST API. Use Chatter in Apex to create custom Chatter experiences in
Salesforce.

74. What the Concurrent Request Limit is and Why it Exists in Salesforce?
Answer :
The multi tenant [Link] platform uses governor limits to ensure that system
resources are available to all customers and to prevent any one customer from
monopolizing them. If a governor limit is exceeded, the associated execution
governor limit issues a runtime exception that cannot be handled. When you
design your applications, you can help plan for their growth by keeping these
limits in mind.

One of the limits customers frequently reach is the concurrent request limit.
Once a synchronous Apex request runs longer than 5 seconds, it begins counting
against this limit. Each organisation is allowed 10 concurrent long-running
requests. If the limit is reached, any new synchronous Apex request results in a
runtime exception. This behavior occurs until the organization’s requests are
below the limit.

Ultimately, this limit is in place to protect the user experience. Once the limit is
reached, new synchronous Apex requests are denied. This behaviour can be
disruptive to your work.

Some useful tips:

 Convert synchronous processes to asynchronous processes. Batch Apex


might be a viable alternative. Limit synchronous Web service callout.
 Use the Streaming API instead of polling
 Tune SOQL and DML operations. Make sure that your queries are selective.
Limit the number of records in your list views. Avoid data skew.
75: What is custom metadata type ?
Answer : Custom metadata is customizable, deployable, packageable, and
upgradeable application metadata. First, you create a custom metadata type,
which defines the form of the application metadata. Then you build reusable
functionality that determines the behavior based on metadata of that type.
Similar to a custom object or custom setting, a custom metadata type has a list
of custom fields that represent aspects of the metadata.
Before Custom metadata type, we were using Custom settings of List type.
Problem with custom setting was that, during migration or in packages, data
were not migrated. We had to either use data loader or some API to create initial
data. However, if we package custom metadata type or migrate it, data will also
be migrated along with it.

76: Which component in Salesforce ends with __mdt and __s ?


Answer : Custom metadata types ends with __mdt (meta data type), just like
custom object or custom fields ends with __c.

When we create Geolocation field in Salesforce, lets say by


name location__c then internally Salesforce creates subfields with
extension __s.
In this case location_latitude__s and location_longitude__s.

77: Which interface needs to be implemented in Apex to be used in Flow ?


Answer : We can execute apex as well using flow by annotating it
with @InvocableMethod and marking method as static. However this method
only takes one parameter of type list. If we want to send multiple parameters,
then simplest way is to create comma separated list of argument and pass it. In
this method, we can break it and use according.
Below is sample code

Global class Flow_UpdateContactField {


@InvocableMethod
public static void performUpdate(List<String> lstCSV){
List<String> recIds = lstCSV[0].split(',');
// 0 - ContactId, 1-field1__c
Contact objCon = new Contact(Id=recIds[0], field1__c=recIds[1]);
update objCon;
}
}

78: How to get the list of all available sobject in salesforce database using Apex
(Dynamic Apex) ?
Answer :
Map<String, [Link]> m = [Link]();

79. How to display error messages in the visualforce page ?


Answer :
In Apex use below code to create the error message for visualforce.
[Link]( new [Link] ([Link],
'Required fields are missing. '));
And in Visualforce page, add below tag where you want to display the error
message which display the error message.

<apex:pageMessages > </apex:pageMessages>

80: How to read the parameter value from the URL in Apex?
Answer :
Consider that the parameter name is AccountName then use below code snippet:

String objAccountName =
[Link]().getParameters().get('AccountName');

81. How to get the debug log of Connection user in salesforce to salesforce
Integration?
Answer :
When configuring Debug Logs, you cannot choose a Salesforce to Salesforce
Connection User from the User Lookup, but there is a workaround to achieve
this.

To begin capturing Debug Logs for a Connection User open the following URL in
your browser:
[Link]
gLogUser?retURL=%2Fsetup%2Fui
%[Link]&UserLookupInput_lkid=YYYYYYYYYYYYYY
&UserLookupInput=Connection%20User
Replace YOURSALESFORCEINSTANCE with your salesforce instance,
UserLookupInput_lkid is the ID of the Connection User and UserLookupInput is
the User name. You can find the user ID of the connection user, by inspecting the
CreatedById for a record created by this user. (eg. via eclipse or [Link]
explorer)
82. What are different user licenses available in salesforce and explain them?
Answer : Below is the list of licenses available in salesforce
1) Salesforce : Full access to salesforce CRM and appExchange
2) Salesforce Platform : Access only to Custom apps but not standard CRM
3) [Link] One App : Designed to access only one custom app with
unlimited number of tabs
4) [Link] Knowledge Subscription : Grant user access to [Link] Light
app or [Link] enterprise app but no CRM functionality
5) Knowledge Only User :Designed for users who only need access to the
Salesforce Knowledge app
6) Chatter Free : User has access to chatter which includes feeds, profiles, files
and groups
7) Chatter External : Designed to allow customers in Chatter groups.
Customers are users outside of a company’s email domain.
8) Chatter Only : User has access to Groups, feeds, people, profiles and files
along with access to view accounts and contacts, modify custom objects and use
CRM contents, Ideas.

83. What is the difference between Customer portal and Partner portal?
Answer : Traditionally Partner Portal is part of companies Partner Channel Sales
efforts. It is a portal focused more on Sales force automation and the efforts of
those partners that sell your products to nurture the leads you pass to them, the
leads they enter in themselves and the convert to Opportunity and subsequent
sale.

Customer Portal on the other hand is more focused on the Service and Support of
one’s Customers.

The feature differences are that Partner Portal exposes the Leads and
Opportunity objects whereas the Customer Portal does not. However, only the
top tier of Partner licensing (Gold Partner licenses) exposes the Case object
whereas this is standard in the Customer Portal.

84. What is a Solution in Salesforce?


Answer :
• An answer to a common question or problem
• Enables Customer Support users get up to speed quickly
• Enables Support teams to answer questions quickly and consistently
• Customers search for and browse published Solutions to self assist
• Content-Rich Solutions are an enhancement to the Solution Object which allows
solution writers to integrate rich text and
images into their solutions to completely solve a problem

85. Explain Lead conversion?


Answer :
Lead can be converted in [Link] and the converted information is
mapped to the appropriate business objects – Account, Contact or Opportunity
• The system automatically maps standard lead fields to standard account,
contact, and opportunity fields
• For custom lead fields, your administrator can specify how they map to custom
account, contact, and opportunity fields
• The system assigns the default picklist values for the account, contact, and
opportunity when mapping any standard lead picklist fields that are blank. If your
organization uses record types, blank values are replaced with the default
picklist values of the new record owner.
• If the lead has a record type, the default record type of the new owner is
assigned to records created during lead conversion.

86. Explain the lead conversion process in salesforce?


Answer : When you convert a lead, the standard lead fields are automatically
converted to the new account, contact, and, optionally, an opportunity using the
information from the lead.
Custom lead fields are converted to custom account, contact, and opportunity
fields as specified by your administrator.
All open and closed activities from the lead are attached to the account, contact,
and opportunity.

87. What are differences between workflows and approval process?


Answer :
The key difference between workflows and approval process are as below
Workflow rules consist of single step and a single action where as approval
process has multiple steps and different actions.
Workflow rules trigger automatically and the rules when triggered are not visible
to the user. Approval process on the other hand, contains multiple step s each
requiring a specific "I Approve or Reject" user action by the specified approvers.

88. Tell me about Jump Start Wizard versus Standard Wizard in Salesforce?
Answer :
The Jump Start wizard creates a one-step approval process for you in just a few
minutes
The Standard Wizard is useful for complex approval processes.

Jump Start Wizard


• The jump start wizard is useful for simple approval processes with a single
step.
• Use the jump start wizard if you want to create an approval process quickly by
allowing Salesforce to automatically choose some default options for you.

Standard Wizard
• The standard wizard is useful for complex approval processes.
• Use it when you want to fine tune the steps in your approval process.
• The standard wizard consists of a setup wizard that allows you to define your
process and another setup wizard that allows you to define each step in the
process.

89. What is the Parallel Approval Routing ?


Answer :
Parallel Approval Routing is sending approval requests to multiple approvers in a
single step Wait for approval from all the approvers or wait for approval from any
one
Configure an approval step to request approval from any combination of multiple
users and related users
Configure 25 parallel approvers at each step.

90. What are the Time-Dependent Workflow – Considerations ?


Answer :
Maximum of 10 time triggers per rule
Maximum of 40 actions (10 x 4 types) per time trigger, and 80 actions per
workflow rule
Workflow default user must be set up before creating time-based rules
Precision limited to hours or days
Cannot convert leads with time-dependent actions in the Workflow Queue
Time triggers cannot be added to or removed from activated workflow rules
Not possible to create a time-dependent action associated to a rule with a trigger
type of Every time the record is created or updated

91. What are the Time-Dependent Workflow Limitations ?


Answer :
Time triggers don’t support minutes or seconds.
Time triggers can’t reference the following:
• DATE or DATETIME fields containing automatically derived functions, such as
TODAY or NOW.
• Formula fields that include related-object merge fields.

You can’t add or remove time triggers if:


• The workflow rule is active.
• The workflow rule is deactivated but has pending actions in the queue.
• The workflow rule evaluation criteria are set to Evaluate the rule when a
record is: created, and every time it’s edited.
• The workflow rule is included in a package

92. We have a Time Based Workflow and there is Action scheduled to


be executed. If we Deactivate the workflow, Scheduled actions will be removed
from queue or not?
Answer :
Even after deactivation of workflow, its action will be active in queue.

93. We have Time Based Workflow and there is action scheduled to be executed.
Can we delete that workflow?
Answer : If a workflow has any pending time dependent action, then we cannot
delete the workflow.

94. How to clear the Time based workflow action queue?


Answer :
Two ways to achieve this:
1. Make criteria false for all those records.
2. Navigate to Set up -> Monitoring -> Time Based Workflow, search for
scheduled actions and remove from queue.

95. When the Add Time Trigger button is unavailable?


Answer :
The evaluation criteria are set to Evaluate the rule when a record is: created, and
every time it’s edited.
The rule is activated.
The rule is deactivated but has pending actions in the workflow queue.

96. In salesforce which fields are indexed automatically?


Answer :
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

97. What is a Category in Salesforce ?


Answer :
• Mechanism to organise Solutions
• Solutions may be associated to one or more Categories
• Categories make up a Solution Category tree structure
What are Suggested Solutions?
• The suggested solutions feature displays up to ten relevant solutions that may
help users and customers solve a particular case from the case detail page and
the Self-Service portal.
• Suggested Solutions can be enabled for the following:
Cases tab
Self Service Portal
Case auto-response rules and emails.

98. What are different Organization Wide Defaults? Explain each of them?
Answer :
Below are the different OWD values :
Private :
If the OWD for an object is set to private, then only the owner, and users
above that role in role hierarchy, can view, edit and report on those records
Public Read Only :
If the OWD for an object is set to Public Read Only, then all users can view and
report on records but they cannot edit them. Only the record owner and the
users above that role in the role hierarchy can edit the records
Public Read/Write :
If the OWD for an object is set to Public Read/Write, then all users can view, edit
and report on all records. But only owner of the record can delete the records.

Public Read/Write/Transfer :
This is available only for Case and Lead objects
If the OWD for an object is set to Public Read/Write/Transfer then, all users can
view, edit, Transfer and report on all the records but only owner of the record
can delete the records

Public Full Access :


This is available only for Campaign object.
If the OWD for Campaigns are set Public Full Access then, all users can view,
edit, delete and report on all records.

No Access, View Only or Use :


This is available only for Price Book object.
If the OWD for Price Book is set Use then, all users can access the Price Book
information and as well as using the Price Book configuration for Opportunities
with Products.
If the OWD for Price Book is set View Only then, all users can access the Price
Book information but not to use that Price Book detail in Opportunities with
Products
If the OWD for Price Book is set No Access then, it restricts users from accessing
information for Price Book and Prices.

Controlled By Parent :
If the OWD for any object is set as Controlled By Parent, then user can perform
an action on the record based on whether they can do the same on the parent
record associated with it.

99. What are differences between custom settings and custom objects?
Answer :
Custom Settings:
1. Custom settings are SOQL inexpensive
2. We can’t write triggers on custom settings
3. Fields on which we can create custom settings are restricted like picklists,
lookups and formula fields can’t be created in custom settings
4. No Page layouts, record types, validation rules and workflow rules can be used
on custom settings.
5. Custom Settings SOQL is faster than custom objects.

Custom Objects:
1. Custom Objects are SOQL Expensive
2. We can have triggers on custom objects
3. No restrictions on creation of fields
4. Can be used on Custom objects
5. Custom objects SOQL not fast as a custom Settings .

100. How to get all the required fields of sObject dynamically?


Answer :
There is no direct property available in Apex dynamic API to represent the
required field. However there is another way to know about it.
If any fields have below three properties then it is mandatory field.
1. If it is Creatable
2. If it is not nillable and
3. If it does not have any default value

Map<String, [Link]> m = [Link]() ;


[Link] s = [Link]([Link]) ; // Like Account object
[Link] r = [Link]() ;
Map<String,[Link]> fields = [Link]() ;
for(String f : [Link]())
{
[Link] desribeResult = [Link](f).getDescribe();
if( [Link]() && ![Link]() && !
[Link]() )
{
//This is mandatory / required field
}
}

101. What is the difference between public cloud & private cloud in salesforce? Is
[Link] a public cloud or private cloud?
Answer :
Public Cloud: Could services are provided "as a service" over the Internet with
little or no control over the underlying technology infrastructure. More than one
tenant can use the same resources.
Private Cloud: This also offers activities and functions "as a service" but is
deployed over a company intranet or hosted data center. This is private product
for a company or organization offering advance security.
[Link]: Is a public cloud as it is hosted on [Link] data centers
and data of more than one tenant resides on same servers.

102. What is the difference between apex:pageMessages, apex:pageMessage,


apex:Message and apex:Messages?
Answer :
apex:PageMessages:

This component displays all messages that were generated for all components
on the current page, presented using the salesforce styling. This will display both
salesforce generated messages as well as custom messages added to the
ApexPages class
apex:PageMessage:

Apex:PageMessage is a component that adds single message on the page. This


is used to display custom message using the salesforce formatting

apex:Message:

apex:Message is used to display an error on only a specific field. It is used to


allow developers to place field specific errors in specific location.

apex:Messages:

apex:Messages is similar to apex:Message but it displays all errors

103. What are the aggregate functions supported by salesforce SOQL?


Answer :
Following aggregate functions are supported by salesforce SOQL
1. SUM()
2. MIN()
3. MAX()
4. COUNT()
5. AVG()
6. COUNT_DISTINCT()

104. Write a sample aggregate query or explain how to write a aggregate


queries?
Answer :
The return types of Aggregate functions are always an array of AggregateResult.

Sample Code

AggregateResult[] ar = [select AVG(Amount) aver from Opportunity];


Object avgAmt = ar[0].get('aver’);

105. Write a code to find the average Amount for all your opportunities by
campaign?
Answer :
AggregateResult[] arList = [select CampaignId, AVG(amount) from Opportunity
group by CampaignId];
for(AggregateResult ar : arList){
[Link]('CampaignId ' + [Link]('CampaignId'));
[Link]('Average Amount' + [Link]('expr0'));
}

106. What are groups in SFDC and what is their use in salesforce?
Answer :
Groups are set of users. They can contain individual users, other groups, the
users in a particular role or territory, or the users in a particular role or territory
plus all of the users below that role or territory in the hierarchy.
There are two types of groups:
• Public groups: Only administrators can create public groups. They can be used
by everyone in the organization.
• Personal groups: Each user can create groups for their personal use.
You can use groups in the following ways:
• To set up default sharing access via a sharing rule
• To share your records with other users
• To specify that you want to synchronize contacts owned by others users
• To add multiple users to a Salesforce CRM Content library
• To assign users to specific actions in Salesforce Knowledge

107. Write a syntax and structure of scheduler class?


Answer :
Sample class

global class ScheduleDemo implements Schedulable{


global void execute(SchedulableContext sc){
BatchClass b = new BatchClass();
[Link](b);
}
}

108 .How to schedule export or take the backup of salesforce?


Answer :
Step by Step Instruction:

 Click Setup >Data Management > Data Export > Schedule Export.
 Select the desired encoding for your export file. Leaving the default is fine.
 Check the Include in export checkbox if you want to include attachments
in the export (optional)
 Leave the default Replace carriage returns with spaces if you want your
export files to have spaces instead of carriage returns.
 Select Weekly as the frequency for the exports.
 Choose start and end dates. Set the end date to sometime in the distant
future such as 20 years from the begin date.
 Set the time of day for your scheduled export. The export is put in a job
queue and the exact time of the export will depend on the amount of activity in
the queue.
 You can select the types of data to include in your export. It is best to
include all data in your export file. This will make sure all your organizations data
is exported.
 Click Save.

Points to Remember:

 Formula and roll-up summary fields are never included in exports.


 Articles are not included from exports.
 The export notification email is sent to the email address on file for the
user who created the scheduled export. There is no way to indicate another
email address. If as an Administrator you want the email to go to another person,
have them grant you login access, login as them and schedule the data export.
 Important:
 Scheduled backup exports of your data are limited to weekly exports.
 You have 48 hours from the time you are notified the backup is available
to download the backup file.
 The email notification for backups goes to the email address in Salesforce
of the person logged in who schedules the backup.

109. How to import attachments using Data Loader in salesforce?


Answer :
Please follow the instructions below.

1. Create an [Link] file with the following column headers:


• ParentId - ID of the record to which the attachment should be associated
• Name - Name of the attachment
• ContentType - Format of the extension (e.g. .xls, .pdf, etc)
• OwnerID - ID for the owner of the attachment
• Body - File path to the Attachment on your local machine (C:\Attachments\
[Link])
2. Log in to the Data Loader.
3. Select the "Insert" command.
4. In the 'Select Sforce Object' step, select the 'Attachments’ object. This object
is not displayed by default hence check the 'Show all Sforce Objects' checkbox.
5. Choose the [Link] file.
6. In the mapping step, map the following fields:
• Parent ID
• Name
• Owner ID
• Body - Make sure to map the Body column which you created previously with
the file extension. This is how you designate the file and location of the
attachments to be inserted.
7. Click "OK" to start the upload.

110. What is the difference between custom controller and extension in


salesforce?
Answer :
Custom Controller: A custom controller is an Apex class that implements all of
the logic for a page without leveraging a standard controller. Use custom
controllers when you want your Visualforce page to run entirely in system mode,
which does not enforce the permissions and field-level security of the current
user.
Controller extension: A controller extension is an Apex class that extends the
functionality of a standard or custom controller. Use controller extensions when:
• You want to leverage the built-in functionality of a standard controller but
override one or more actions, such as edit, view, save, or delete.
• You want to add new actions.
• You want to build a Visualforce page that respects user permissions. Although
a controller extension class executes in system mode, if a controller extension
extends a standard controller, the logic from the standard controller does not
execute in system mode. Instead, it executes in user mode, in which
permissions, field-level security, and sharing rules of the current user apply.
A controller extension is any Apex class containing a constructor that takes a
single argument of type [Link] or
CustomControllerName, whereCustomControllerName is the name of a custom
controller you want to extend.
Note: Although custom controllers and controller extension classes execute in
system mode and thereby ignore user permissions and field-level security, you
can choose whether they respect a user's organization-wide defaults, role
hierarchy, and sharing rules by using the with sharing keywords in the class
definition.

111. Difference between with sharing and without sharing in salesforce ?


Answer :
By default, all Apex executes under the System user, ignoring all CRUD, field-
level, and row-level security (that is always executes using the full permissions of
the current user).
without sharing:
Enforcing the User’s Permissions, Sharing rules and field-level security should
apply to the current user.
For example:
public with sharing class sharingClass {
// your Code here
}
without sharing:
Not enforced the User’s Permissions, Sharing rules and field-level security.
For example:
public without sharing class noSharing {
// your Code here
}
Enforcing the current user’s sharing rules can impact: (with sharing)
SOQL and SOSL queries – A query may return fewer rows than it would operating
in system context.
DML operations – An operation may fail because the current user doesn’t have
the correct permissions. For example, if the user specifies a foreign key value
that exists in the organization, but which the current user does not have access
to.

112. What are email services in salesforce and explain how we can use them in
code?
Answer :
Email services are automated processes that use apex class to process the
contents, headers and attachment of an inbound email.

Sample code
Use Case: create a contact record if the inbound email subject is Create Contact
and body contains contact name

global CreateContactFromEmail implements [Link]{


global [Link]
handleInboundEmail([Link] email, [Link]
envelop){
[Link] res = new [Link]();
String strToCompare = 'Create Contact’;
If([Link](strToCompare)){
Contact c = new Contact();
[Link] = [Link]();
insert c;

//save text attachments

for([Link] att : [Link]){


Attachment a = new Attachment();
[Link] = [Link];
[Link] = [Link]([Link]);
[Link] = [Link];
insert attachment;
}

//save binary attachments

for ([Link] bAttachment :


[Link]) {
Attachment attachment = new Attachment();
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
insert attachment;
}
}
[Link] = true;
return res;
}
}

113. What is Wrapper Class in Apex Salesforce ?


Answer :
Wrapper class is collections of different data type, subject etc.

In following example we are bind Account ,Opportunity standard object. We


query and perform
business logic on the Collection of elements across unrelated objects with the
custom data type.

Visual Force Page:

<apex:page controller="wrapperDemoCtrl">

<apex:pageBlock title="Account From wrapper Class">

<apex:pageBlockTable value="{!wraccount}" var="wra">

<apex:column value="{![Link]}"/>

</apex:pageBlockTable>

</apex:pageBlock>

<apex:pageBlock title="Opportunity From wrapper Class">

<apex:pageBlockTable value="{!wraoppn}" var="wropp">

<apex:column value="{![Link]}"/>

</apex:pageBlockTable>

</apex:pageBlock>

</apex:page>

Apex Controller :

public class wrapperDemoCtrl {

public list<wrapperClass> wraplist{get;set;}

public list<wrapperClass> getwraccount()


{
list<Account>acclist=[select Id,Name from Account limit 3];
wraplist= new list<wrapperClass>();
for(Account acn: acclist)
{
[Link](new wrapperClass(acn));
}
return wraplist;
}
public list<wrapperClass> getwraoppn()
{
list<Opportunity>opplist=[select Id,Name from Opportunity limit 3];
wraplist= new list<wrapperClass>();
for(Opportunity opn:opplist )
{
[Link](new wrapperClass(opn));
}
return wraplist;
}

public class wrapperClass{

public Account acc {get;set;}


public Opportunity op {get;set;}

public wrapperClass(Account accn){

acc= accn;
}
public wrapperClass(Opportunity opn)
{
op=opn;

}
}
}

114. How can we hard delete a record using a Apex class/by code?
Answer :
ALL ROWS key word can be used to get all the records including records in the
recycle bin.
Below is the sample code to delete contact records from recycle bin
List<Contact> dContactList=[Select ID From Contact Where IsDeleted = true
limit 199 ALL ROWS];
[Link]( dContactList );

How do you do File Upload using visualforce?


Answer :
Below is the code sample of file upload in visualforce
<!-- Upload a file and put it in your personal documents folder-->
<!-- Page: -->
<apex:page standardController="Document" extensions="documentExt">
<apex:messages />
<apex:form id="theForm">
<apex:pageBlock>
<apex:pageBlockSection>
<apex:inputFile value="{![Link]}" filename="{![Link]}"/>
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
/*** Controller ***/
public class documentExt {
public documentExt([Link] controller) {
Document d = (Document) [Link]();
[Link] = [Link](); //this puts it in My Personal Documents
}
}

115. Explain Class Constructors with example?


Answer :
• A constructor is a special method used to create (or instantiate) an object out
of a class definition.
• Constructors never have explicit return types.
• Constructors have the same name as the class.
• Classes have default, no-argument, public constructor if no explicit
constructors is defined.
• If you create a constructor that takes arguments and still want a no-argument
constructor, you must explicitly define one.
• Constructors can be overloaded, meaning you can have multiple constructors
with different parameters, unique argument lists, or signatures.
• Constructors are called before all other methods in the class.
For Example:
public class TestObject2 {
private static final Integer DEFAULT_SIZE = 10;
Integer size;
//Constructor with no arguments
public TestObject2() {
this(DEFAULT_SIZE); // Using this(…) calls the one argument constructor
}
// Constructor with one argument
public TestObject2(Integer ObjectSize) {
size = ObjectSize;
}
}
New objects of this type can be instantiated with the following code:
TestObject2 myObject1 = new TestObject2(20);
TestObject2 myObject2 = new TestObject2();

116. What are the available Trigger Events?


Answer :
There are 6 trigger events available.
1. Insert
2. Update
3. Delete
4. Merge
5. Upsert
6. Undelete

117. What are the available Trigger contest variables?


Answer :
Below are the list of Trigger context variables
1. isBefore
2. IsAfter
3. isInsert
4. IsUpdate
5. isDelete
6. isUndelete
7. isExecuting
8. new
9. old
10. newMap
11. oldMap
12. size

118. Let’s say we have to update the same record in After Trigger context. Is
there any way or workaround?
Answer :
If we create a new instance of a sObject in the Apex Trigger in memory using the
Id of the newly created record as provided in the After Trigger context, we can
perform an Update DML statement and not get a read only error. This is because
in Apex, the SObject is seen as a new reference (even though the records have
the same SFDC ID) and therefore is eligible for DML operations. The below
snippet of code illustrated this working and not working.
List<Contact> originals = new List<Contact>();
if([Link]().size() > 0)
{
for(Contact origContact : [Link]())
{
Contact mirrorContact = [Link]([Link]);
//origContact.Linked_Contact__c = [Link]; //Link the Original
Record i.e. Mirror Record WILL FAIL
Contact origContactUpdate = new Contact(Id=[Link],
Linked_Contact__c = [Link]); //This will WORK
[Link](origContactUpdate);
}
//update [Link](); //Update the Records -> THIS WILL FAIL AS ITS
ORIGINAL RECORDS IN MEMORY
update originals;
}

119. How to get the picklist value in Apex class?


Answer :
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 <apex:selectOptions>.
Code Example:
Let’s say we have a custom object called OfficeLocation__c. This object contains
a picklist field Country__c.
The first thing we need to do, within our controller is use the getDescribe()
method to obtain information on
the Country__c field:
[Link] fieldResult =
OfficeLocation__c.Country__c.getDEscribe();
We know that Country__c is a picklist, so we want to retrieve the picklist values:
List<[Link]> ple = [Link]();
The only thing left for us to do is map the picklist values into an
<apex:selectOptions> tag can use for display. Here is the entire method from
our controller to do this:
public List<SelectOption> getCountries()
{
List<SelectOption> options = new List<SelectOption>();

[Link] fieldResult =
OfficeLocation__c.Country__c.getDescribe();
List<[Link]> ple = [Link]();

for( [Link] f : ple)


{
[Link](new SelectOption([Link](), [Link]()));
}
return options;
}
With our controller logic all complete, we can call the getCountries() method
from our Visualforce page, and populate the <apex:selectList> tag:
<apex:selectList id="countries" value="{!Office_Location__c.Country__c}"
size="1" required="true">
<apex:selectOptions value="{!countries}"/>
</apex:selectList>

120. What are the Salesforce annotations ?


Answer :
Apex annotations modify the way a method or class is used.
Below is the list of annotations supported by salesforce :
@Deprecated:
Use the deprecated annotation to identify methods, classes, exceptions,
enums, interfaces, or variables that can no longer be referenced in subsequent
releases of the managed package in which they reside. This is useful when you
are re-factoring code in managed packages as the requirements evolve. New
subscribers cannot see the deprecated elements, while the elements continue to
function for existing subscribers and API integrations.
@Future:
Use the future annotation to identify methods that are executed
asynchronously. When you specify future, the method executes when Salesforce
has available resources.
To test methods defined with the future annotation, call the class
containing the method in a startTest, stopTest code block. All asynchronous calls
made after the startTest method are collected by the system. When stopTest is
executed, all asynchronous processes are run synchronously.
@IsTest:
Use the isTest annotation to define classes or individual methods that
only contain code used for testing your application. The isTest annotation is
similar to creating methods declared as testMethod.
@ReadOnly:
The @ReadOnly annotation allows you to perform unrestricted queries
against the [Link] database. All other limits still apply. It's important to note
that this annotation, while removing the limit of the number of returned rows for
a request, blocks you from performing the following operations within the
request: DML operations, calls to [Link], calls to methods annotated
with @future, and sending emails.

@RemoteAction:
The RemoteAction annotation provides support for Apex methods used in
Visualforce to be called via JavaScript. This process is often referred to as
JavaScript remoting.

@TestVisible:
Use the TestVisible annotation to allow test methods to access private or
protected members of another class outside the test class. These members
include methods, member variables, and inner classes. This annotation enables a
more permissive access level for running tests only.

Apex REST annotations:

@RestResource(urlMapping='/yourUrl'):
The @RestResource annotation is used at the class level and enables you
to expose an Apex class as a REST resource.
@HttpDelete:
The @HttpDelete annotation is used at the method level and enables you
to expose an Apex method as a REST resource. This method is called when an
HTTP DELETE request is sent, and deletes the specified resource.
@HttpGet:
The @HttpGet annotation is used at the method level and enables you to
expose an Apex method as a REST resource. This method is called when an HTTP
GET request is sent, and returns the specified resource.
@HttpPatch:
The @HttpPatch annotation is used at the method level and enables you
to expose an Apex method as a REST resource. This method is called when an
HTTP PATCH request is sent, and updates the specified resource.
@HttpPost:
The @HttpPost annotation is used at the method level and enables you to
expose an Apex method as a REST resource. This method is called when an HTTP
POST request is sent, and creates a new resource.
@HttpPut:
The @HttpPut annotation is used at the method level and enables you to
expose an Apex method as a REST resource. This method is called when an HTTP
PUT request is sent, and creates or updates the specified resource.

121. What are the Trigger Best Practices ?


Answer :
Best Practice #1: One Trigger Per Object
A single Apex Trigger is all you need for one particular object. If you develop
multiple Triggers for a single object, you have no way of controlling the order of
execution if those Triggers can run in the same contexts. Many times, the order
of execution doesn’t matter but when it does matter, it’s nearly impossible to
maintain proper flow control. A single Trigger can handle all possible
combinations of Trigger contexts which are:

 before insert
 after insert
 before update
 after update
 before delete
 after delete
 after undelete

So as a best practice, create one Trigger per object and let it handle all of the
contexts that you need. Here is an example of a Trigger that implements all
possible contexts:

trigger OpportunityTrigger on Opportunity (


before insert, before update, before delete,
after insert, after update, after delete, after undelete) {

// trigger body

}
Best Practice #2: Bulkify your Helper Methods
Make sure any code that runs a query or DML operation does it in a bulk manner
and doesn't execute within an iteration or a for loop. Executing queries or DML
operations within an iteration adds risk that the governor limits will be exceeded.
This is also true for any helper or utility methods an Apex request executes.
Governor limits are calculated at runtime. After the request is initiated (Trigger,
Visualforce page, etc.), any Apex code executed in that transaction applies and
shares the governor limits. So if a trigger uses some Apex methods written in a
helper class, it's important that those shared Apex methods are properly
designed to handle bulk records. These methods should be written to be invoked
with a set of records, especially if the method has a SOQL query or DML
operation.
For example, if the Apex method performs a SOQL query, that method should
receive a collection (Array, List, Set, etc.) of records so when it performs the
query, it can perform the query for all records in the Apex transaction.
Otherwise, if the Apex method is called individually for each record being
processed, the Apex transaction will inefficiently run queries and possibly exceed
the allowed number of queries allowed in that transaction. The same is true for
DML statements in Apex methods.
So please make sure any utility or helper methods are efficiently written to
handle collections of records. This will avoid unnecessarily executing inefficient
queries and DML operations.

Best Practice #3: Logic-less Triggers


Another widely-recognized best practice is to make your Triggers logic-less. That
means, the role of the Trigger is just to delegate the logic responsibilities to
some other handler class. There are many reasons to do this. For one, testing a
Trigger is difficult if all of the application logic is in the trigger itself. If you write
methods in your Triggers, those can’t be exposed for test purposes. You also
can’t expose logic to be re-used anywhere else in your org.
Good old OO principles tell us that this is a bad practice. And to top it all off,
cramming all of your logic into a Trigger is going to make for a mess one day. To
remedy this scenario, just create a handler class and let your Trigger delegate to
it. Here is an example:
trigger OpportunityTrigger on Opportunity (after insert) {
[Link]([Link]);
}
And the handler class:

public class OpportunityTriggerHandler {

public static void handleAfterInsert(List opps) {


// handler logic
}
}

Best Practice #4: Avoid SOQL Queries or DML statements inside FOR
Loops
A common mistake is that queries or DML statements are placed inside a for
loop. There is a governor limit that enforces a maximum number of SOQL
queries. There is another that enforces a maximum number of DML statements
(insert, update, delete, undelete). When these operations are placed inside a for
loop, database operations are invoked once per iteration of the loop making it
very easy to reach these governor limits.
Instead, move any database operations outside of for loops. If you need to query,
query once, retrieve all the necessary data in a single query, then iterate over
the results. If you need to modify the data, batch up data into a list and invoke
your DML once on that list of data.

Best Practice #5: Using Collections, Streamlining Queries, and Efficient


For Loops
It is important to use Apex Collections to efficiently query data and store the
data in memory. A combination of using collections and streamlining SOQL
queries can substantially help writing efficient Apex code and avoid governor
limits.

Best Practice #6: Querying Large Data Sets


The total number of records that can be returned by SOQL queries in a request is
50,000. If returning a large set of queries causes you to exceed your heap limit,
then a SOQL query for loop must be used instead. It can process multiple
batches of records through the use of internal calls to query and queryMore.

For example, if the results are too large, the syntax below causes a runtime
exception:
//A runtime exception is thrown if this query returns enough records to exceed
your heap limit.
Account[] accts = [SELECT id FROM account];

Instead, use a SOQL query for loop as in one of the following examples:

// Use this format for efficiency if you are executing DML statements
// within the for loop. Be careful not to exceed the 150 DML statement limit.

Account[] accts = new Account[];

for (List<Account> acct&nbsp;: [SELECT id, name FROM account


WHERE name LIKE 'Acme']) {
// Your logic here
[Link](acct);
}

update accts;

Let the [Link] platform chunk your large query results into batches of 200
records by using this syntax where the SOQL query is in the for loop definition,
and then handle the individual datasets in the for loop logic.

Best Practice #7: Use of the Limits Apex Methods to Avoid Hitting
Governor Limits
Apex has a System class called Limits that lets you output debug messages for
each governor limit. There are two versions of every method: the first returns the
amount of the resource that has been used in the current context, while the
second version contains the word limit and returns the total amount of the
resource that is available for that context.

122. What are Apex Unit Tests?


Answer:
To facilitate the development of robust, error-free code, Apex supports the
creation and execution of unit tests. Unit tests are class methods that verify
whether a particular piece of code is working properly. Unit test methods take no
arguments, commit no data to the database, send no emails, and are flagged
with the testMethod keyword or the isTest annotation in the method definition.
Also, test methods must be defined in test classes, that is, classes annotated
with isTest.
For example:
@isTest
private class myClass {
static testMethod void myTest() {
// code_block
}
}

This is the same test class as in the previous example but it defines the test
method with the isTest annotation instead.
@isTest
private class myClass {
@isTest static void myTest() {
// code_block
}
}

123. What are the Unit Test Considerations ?


Answer :
Here are some things to note about unit tests.

 Starting with Salesforce API 28.0, test methods can no longer reside in
non-test classes and must be part of classes annotated with isTest. See the
TestVisible annotation to learn how you can access private class members from a
test class.
 Test methods can’t be used to test Web service callouts. Instead, use
mock callouts. See Test Web Service Callouts and Testing HTTP Callouts.
 You can’t send email messages from a test method.
 Since test methods don’t commit data created in the test, you don’t have
to delete test data upon completion.
 If a test class contains a static member variable, and the variable’s value
is changed in a testSetup or test method, the new value isn’t preserved. Other
test methods in this class get the original value of the static member variable.
This behavior also applies when the static member variable is defined in another
class and accessed in test methods.
 For some sObjects that have fields with unique constraints, inserting
duplicate sObject records results in an error. For example, inserting
CollaborationGroup sObjects with the same names results in an error because
CollaborationGroup records must have unique names.
 Tracked changes for a record (FeedTrackedChange records) in Chatter
feeds aren't available when test methods modify the associated record.
FeedTrackedChange records require the change to the parent record they're
associated with to be committed to the database before they're created. Since
test methods don't commit data, they don't result in the creation of
FeedTrackedChange records. Similarly, field history tracking records (such as
AccountHistory) can't be created in test methods because they require other
sObject records to be committed first (for example, Account).

124. How do you unit test a trigger when you don’t know the required fields?
Answer :
Customers can have validation on custom fields via validation rules and triggers,
so handling that in your unit tests without customer intervention is next to
impossible. The first step to reducing issues is to have your test data populate all
standard fields and ensure the data uses the most common formatting for your
customer base (US style phone numbers and addresses for the US for example).

Beyond that you can use the new Reflection features added to Salesforce in
Summer ’12 to allow customers to create unit test data classes that can be used
by your managed package. Basically you define a test data generation interface
and the customer creates an Apex class to generate data for you. Here’s an
example of using Reflection in a similar manner on the DeveloperForce
blog:[Link]
[Link]

Using the method for unit tests run on install might be problematic as you’d have
to have the customer create the class before they install your package and your
package could only look for the class by name (or iterate through all default
namespace classes and check for the correct interface). However, it’s no longer
necessary for unit tests to run during installation for managed packages and by
default they do not.

The Reflection method requires some coding knowledge on the customer side,
but you could add a tool in your application to generate the custom unit test data
class for the customer.

FYI, it’s no longer necessary for managed package unit tests to succeed in
customer orgs. They’re not required on install, they will no longer prevent
deployment to production and they don’t count as part of the customers unit test
coverage percentage for purposes of deployment. The only exception to that is if
the customer uses ANT and sets the runAllTests parameter to true.

125. How do you write a unit test for a trigger whose only function is to make a
callout?
Answer :
Both future methods and callouts can be unit tested.

To test future methods simply make your call to any future method between
[Link]();and [Link](); statements and the future method will
return when [Link](); is called. See the documentation for the Test class
here: [Link]
Testing callouts is a bit trickier though. Basically in your callout code you check
to see if you’re executing within a unit test context by checking
[Link]() and instead of getting your callout response from an
[Link]() request, you return a pre-built test string instead. There’s
one example of this method here: [Link]
callouts-in-apex-code-part-2/

There’s also an older example of callout unit testing that uses a static variable
you set in your unit test. Just replace that static variable with a call to
[Link]() and their example works fairly well as well. That example
can be found here:[Link]

126. Can I find out if the current user has access to a record without querying?
Answer :
To find out if a particular user has Edit access to a record, use the
UserRecordAccess object. This object is available in API version 24.0 and later.
You can use SOQL to query this object to find out if the user has edit access to
the record in question.

SELECT RecordId, HasEditAccess FROM UserRecordAccess WHERE UserId =


[single ID] AND RecordId = [single ID]

If you want to check a batch of records you can use

SELECT RecordId FROM UserRecordAccess WHERE


UserId=:[Link]() AND HasReadAccess = true ANDRecordId
IN :allRecordIds LIMIT 200

But make sure that allRecordIds is a LIST of IDs. It doesn’t work if allRecordIds is
a SET of IDs. I guess that’s a bug.

Also, only a maximum amount of 200 recordIds can be checked in one query.

1) Write a Apex trigger to update related Contacts phone number whenever Accounts phone number is
updated.

Check answer at : [Link]

2) Write a Visualforce page to display the Account information on entering Account Name as input by
user
Check answer at: [Link]

3) What is Sandbox and explain different types of sandboxes?

Sandboxes are the environment where we develop and test our code before implementing it into the
production. There are four types of Sandboxes.

Developer Sandbox :

1. It can copy only the Metadata from production


2. Data storage is limited to 200 MB
3. Refresh interval is 1 day.

Developer Pro Sandbox:

1. It can also copy only the metadata from production


2. Data storage is limited to 1 GB.
3. Refresh interval is 1 day.

Partial Copy Sandbox:

1. It can copy copy both data and metadata from production.


2. Data storage is limited to 5 GB and can copy maximum of 10000 records from a single object.
3. Refresh interval is 5 days.

Full Copy Sandbox:

1. It is similar to production and everything from production can be copied.


2. No limit on data storage.
3. Refresh interval is 29 days.

4) What is the difference between [Link], [Link], [Link] and [Link]?

[Link]: It returns the list of new records which are updated or inserted on objects

[Link]: It returns the list of old records which are updated or deleted on and from objects.

[Link]: It returns the Map of IDs of new records. Available only for Update and Insert.

[Link]: It returns the Map of IDs of old records. Available only for Update and Delete.

5) What are the different ways to make a field required in an object?

1. While creating the field


2. Using Page Layout
3. Using Validation Rule
4. With the help of Triggers
5. Using Field Level Security
6) Write an apex code to send a mail.

Check answer at : [Link]

7) Explain Deployment through [Link] migration tool using Ant

There are three files associated with ANT:

[Link]: This file will have username, password, server URL


[Link]: This file will have the command which has to be executed. example, Deploycode or
Removecode or retrievecode.
[Link]: This will have the metadata which should be deployed, retrieved or removed.

8) What will happen when we load data from data loader where required field is empty?

1. If the fields are marked Mandatory on page layout level, all the records would be inserted.
2. If the fields are marked Mandatory except page layout, all the records will be inserted apart from
records which don't have data in mandatory field.

9) What is SOSL, SOQL and DML in salesforce?

SOQL: Salesforce Object Query Language. It is used to query data from objects. It is similar to SQL but
here tables are objects and columns are the object fields. Records are retrieved using SELECT keyword.

SOSL: Salesforce Object Search Language. It is similar to SOQL but it returns list of list of objects because
it works on multiple objects. Records are retrieved using FIND keyword.

DML: Data Manipulation Language. This is used to manage records in salesforce. Keywords used are
UPDATE, DELETE, INSERT, UPSERT, MERGE, UNDELETE.

10) Limitation of executing queries in Salesforce:

SOQL:

1. Total number of queries issued in single transaction is 100.


2. Total number of records retrieved is 50000.

SOSL:

1. Total number of queries issued in single transaction is 20.


2. Total number of records retrieved is 2000.

DML:
1. Total number of DML statements in single transaction is 150.
2. Total number of records processed will be 10000.

11) How do you export data from Visualpage into excel and PDF?

We can export data into excel and PDF by using below content inside <apex:page>

EXCEL:contentType="application/[Link]-excel#[Link]"

PDF: renderAs="pdf"

12) Explain the order of execution in Salesforce.

1. System Validation Rule


2. Before Triggers
3. Custom Validation rules
4. After Triggers
5. Assignment rules
6. Auto-Response rules
7. Workflow Rules
8. Before and After triggers are executed again if workflow rules updates or inserts any field
9. Escalation rules
10. Formula fields
11. Sharing Rules
12. Post commit logic

13) What happens when Lead is converted?

Whenever a Lead is converted, Salesforce creates accounts, contacts and optionally opportunity using the
details from Lead.

14) Write a query to find duplicate Email ID associated with Contacts.

Select Email from Contact Group by Email having Count(Email) > 1;

15) Difference between Data Loader and Import Wizard

Data Loader:

1. It can load 5 million records.


2. All standard and custom objects are supported.
3. Schedule regular data imports.
4. It can both Export and Import data.
5. We can delete data using data loader
6. Can be operated either using Use Interface or Command Line.

Import Wizard:
1. It is an internal tool.
2. It can only import data.
3. It can import upto 50 thousand records.
4. Supports all custom objects and few standard objects ( Contacts, Leads, Accounts,Solution and
Campaign)
5. Cannot delete records using Import Wizard.

16) How to insert null values using Data loader?

By checking "Insert Null Values" at Data loader setting page. This option is not available for Bulk API is
enabled.

17) Can we delete records using Workflow?

No. We cannot delete records using workflow.

18) How do you know that Lead is converted?

By checking Lead Status = Closed-Converted. Also, the converted lead wont be searchable unless admin
has given View and Edit converted Lead permission.

19) How to generate single report for multiple objects?

This can be achieved by using Joined Reports which can use multiple report types.

20) What is Custom Label?

Custom Label enables developers to create multilingual apps by presenting information in user's native
[Link] are custom texts, where all the information is pre-loaded by developers which will be
displayed based on the users language). It can be used in both Apex and Visualforce pages.

1. Create Custom Label from setup. let the name of custom label be blog.
2. Use them in Visualforce page : {!$ [Link]}
3. Use them in Apex : [Link]

21) How to delete data from production using Ant?

To delete components, use the same procedure as with deploying components, but also include a delete
manifest file that’s named [Link] and list the components to delete in this manifest.

22) What is Test Class and why do we need it?

A Test class is an apex class that tests your logic written in either apex class or trigger programatcally. A
test class actually ensurs that your code is working fine as expected.

This is an important thing when you are doing deployment in production as salesforce allows deployment
only when your 75% of the code is covered through test classes.
23) Can we delete user? Explain why.

No, we cant delete user and can only deactivate. Users cannot be deleted because any thing created in
Salesforce has "created by" field and if we delete the user, those fields data will also get deleted.

24) How do you expose class to REST webservice?

Making your Apex class available as a REST web service is straightforward. Define your class as global, and
define methods as global static. Add annotations to the class and methods. For example, this sample
Apex REST class uses one method. The getRecord method is a custom REST API call. It’s annotated with
@HttpGet and is invoked for a GET request.

@RestResource(urlMapping='/Account/*')
global with sharing class MyRestResource {
@HttpGet
global static Account getRecord() {
// Add your code
}
}

1) Can we Undelete the records after 20 days of deletion?


No. We can only Undelete the records within 15 days of deletion. Beyond 15 days,
we need to contact Salesforce to get the records.

2) Explain different types of relationship in Salesforce.


There are three important relationships available in Salesforce.

Lookup Relationship:

1. It is a Parent - Child relationship where Parent is not a required field in


Child object.
2. We can have upto 25 lookup relationships in single object.
3. Child record will not be deleted if Parent record is deleted.
4. No impact on Security and Access.

Master-Detail Relationship:

1. It is a Parent - Child relationship where Parent is required field in Child


object.
2. We can have upto 2 Master-Detail relationships in single object.
3. Rollup Summary field can only be created on Master in Master-Detail
relationship.
4. Child record will be deleted, if Parent record is deleted.
5. Access to Master record gives access to Detail records.

Many-to-Many Relationship :

1. Many-to-Many relationship allows each record of one object to link with


multiple records of other object and vice versa.
2. This can be achieved by using Junction object.
3. Junction object is a Custom object with two Master-Detail Relationship.

3) What is a relationship between Accounts and Contacts?


They show lookup relationship because Account field is not required on Contact
page but they also show Master-Detail relationship because contact gets deleted
when Account is deleted.

However, they have lookup relationship and it has a property called


CascadeDelete set to True and this is why Contacts gets deleted when Account is
deleted

4) What is workflow?
Workflows help in automating four actions based on the Evaluation criteria set by
user.
Evaluation Criteria:

1. When Record is Created.


2. When Record is Created and Edited.
3. When record is Created and Edited to meet rule criteria.

Actions:

1. Create new Task.


2. Send Email alert.
3. Field Update.
4. Outbound Message.

5) How to populate account field in contacts without coding?


This can be achieved by using cross object formula field in Contacts.

6) How to get count of Child records in Parent object having lookup relationship.
This can be done using Trigger.
Check Sample Trigger at : [Link]
[Link]

7) What is Custom setting and explain its types?


Custom Setting is similar to Custom Objects which lets you customize org data. It
saves data in Cache memory, which makes is effective as there wont be any
limitation of retrieving data unlike custom object. There are two types of Custom
Settings:

List Custom Setting: This custom setting provides data which will remain same for
entire organization. Every user will view same set of data.

Hierachy Custom Setting: This custom setting provides data which will differ based
on the users access. It will show/restrict data based on users permission.

8) What is Joined Reports?


Joined reports helps in generating a report using multiple report types. Report
types are added as blocks and we can add upto 5 record types in a single Joined
reports.

9) What is Field Bucket?


Field Bucket helps in categorizing records in reports without adding any formula
or extra custom field.

10) What is Dynamic Dashboard?


Dynamic dashboard are used to display information tailored to a
specific user, while normal dashboard shows data only from single
users perspective. Dynamic dashboards should be used when
each user has to see "User-Specific data".
11) What are components of dashboard?

1. Chart
2. Gauge
3. Metric
4. Table
5. Visualforce Pages

12) What are Custom Metadata types.


Custom Metadata types are similar to custom setting with many advance
features. One of the best feature of custom metadata is that both "Data" and
"Metadata" deployed together unlike custom setting where only Metadata is
deployed first and then data has to be moved manually.

13) What is __r?


__r represents a custom relationship between two objects. we use
it when we query a custom relationship from Parent to child or
vice versa.
For example:

Child__c is a child object and Parent__c is a Parent object.

Child to Parent relationship query:


Select ID, Parent__c, Parent__r.Name from Child__c;
Parent to Child relationship query:
Select ID, Name, (Select ID, Name from Child__c) from Parent__c;

14) What will happen if we Undelete the deleted Junction object?


If we Undelete the deleted Junction object, Master-Detail relationship will convert
to Lookup Relationship.

15) What is Batch Apex? How to know status of the Batch Job?
Batch Apex is an asynchronous process which is used to process millions of
records. It uses three methods, Start, Execute and Finish.

Status can be found using below query:

AsyncApexJob a = [Select ID, Status, NumberOfErrors, TotalJobItems,


[Link] from AsyncApexJob where ID =:[Link]()];

16) What is Wrapper Class?


Wrapper Class is a container Class whose instances are the collection of other
objects. It is a custom object defined by developer where he defines the property
of the class.

17) What will happen if we perform "Update" on "After Update" trigger?


It will result in recursive trigger.

18) What is constructor?


A constructor is a special method that is used to initialize a newly created object
and is called just after memory is allocated for the object.

19) Approach to view all records related to user from account whenever
visualpage loads
We will use custom controller with constructor having a query to display data
based on user.

20) Explain different types of controller?


There are three types of controller.

Standard Controller: They are the default controllers provided by [Link].


These standard controllers will have same logic and functionality which are used
in visaulforce pages. Coding is not required.
<apex:page standardcontroller = "contact">

Custom Controller: These are used when developer need a functionality which
cannot be fulfilled by Standard controller. These require coding.
<apex:page controller = "testApexCode">

Extension controller: In order to use both standard and custom controllers


functionality, we use extension controller.
<apex:page standardcontroller = "contact" extensions = "testApexCode">

21) How to make Apex REST call using custom button?


Using below command in custom button:
[Link]("classname", "methodname",{parameter passed to method}

22) How to load attachments using Dataloader?


Create an [Link] file (the name of the file is unimportant) with the
following column headers:

ParentId - ID of the record to which the attachment should be associated


Name - Name of the attachment
ContentType - Format of the extension (e.g. .xls, .pdf, etc)
OwnerID - ID for the owner of the attachment
Body - File path to the Attachment on the local machine (C:\documents and
settings\schun\desktop\attachments\[Link])

Log in to the Data Loader. Select the "Insert" command. In the 'Select Sforce
Object' step, select the 'Show all Sforce Objects' checkbox and then select
"Attachments". Choose the [Link] file. In the mapping step, map the
following fields:

Parent ID
Name
Owner ID
Body - Make sure to map the Body column which you created previously with the
file extension.

This is how you designate the file and location of the attachments to be inserted.
Click "OK" to proceed with the insert. It may take a few minutes but the
attachments should be successfully uploaded to your salesforce org.

23) What is Mixed DML error?


DML operations on certain sObjects, sometimes referred to as setup objects, can’t
be mixed with DML on other sObjects in the same transaction. This restriction
exists because some sObjects affect the user’s access to records in the org. You
must insert or update these types of sObjects in a different transaction to prevent
operations from happening with incorrect access-level permissions. For example,
you can’t update an account and a user role in a single transaction. However,
deleting a DML operation has no restrictions.

24) How to avoid Mixed DML error in Test methods?


Use @future to Bypass the Mixed DML Error in a Test Method.
1) How to overcome recursive Trigger?
Recursive trigger can be handled by using Boolean variable in class. Example:

Class:

public class example{


public static boolean firstRun = true;
}

Trigger:

trigger recursiveTriggerExample on TestObj__c (before Insert){


if([Link]){
[Link] = false;
<perform your task>
}
}

2) What can workflow do, which Trigger can't?


We can schedule workflow on desired time but Trigger can't be scheduled.

3) Difference between Process Builder and Trigger?

Process Builder: Something which evaluates criteria and perform actions when criteria is met.

Trigger: Apex code based evaluation of criteria to set chain of events.

4) Can we delete records using Process builder?


There is no action available in process builder to delete records. However, we can delete records using
Apex method.

To call an Apex Method, add a call apex method to your process and select an Apex class with a
@invocable method annotation.

5) Write a Trigger to populate number of contacts in Account?


Check answer at: [Link]

6) How to call Visualforce page using custom command button?


By using below Javascript:

[Link] = 'apex/visualforcePageName'

1. Create a command button on the object from setup.


2. Click on edit and enter Label and Name as you want
3. Display Type should be "Detail Page Button"
4. Behavior should be "Execute Javascript"
5. Content Source should be "OnClick JavaScript"
6. In the blank body, enter the above JavaScript.

7) What is Sale Process?

A Sale process is used to determine which opportunity stages are selectable when record types are
enabled. In other words,it determines what stage is the opportunity and based on that, what action can
be taken.

8) What is a difference between Role and Profile?

Role:

1. Determines what is visible to the User


2. It is not mandatory to have Role.

Profile:

1. Determines what actions Users are allowed to perform.


2. It is mandatory to have profile.

9) What is Viewstate and how to avoid viewstate error?

Viewstate is a state of visualforce page which helps salesforce to regenerate the page when it comes back
from server.

Viewstate stores following data:

1. All non-transient data members in the associated controller (either standard or custom) and the
controller extensions.
2. Objects that are reachable from a non-transient data member in a controller or controller
extension.
3. The component tree for that page, which represents the page's component structure and the
associated state, which are the values applied to those components.
4. A small amount of data for Visualforce to do housekeeping.

Avoiding viewstate error:

1. Minimize number or forms on page.


2. Declare variable as Transient to reduce viewstate.
3. Use custom objects or custom settings to store large read only data.
4. Refine SOQL to retrieve only the data needed by page.

10) Limitation of Viewstate?

Visualforce imposes a limit of 135K on viewstate.

11) Can we perform DML activities in constructor?

No. We can perform DML activities in constructor.

12) How will you create a new record in Account when a command button is clicked in Custom object
using VF page (without UI)

1. Create a class which will have a function to insert records in new object
2. Call that function in visualforce <apex:page> tag.
3. Call visualforce page using command button (refer question 6)

Example:

Visualforce Page:

<apex:page controller="DMLStatementOnPageloadController" action="{!createAccount}">

</apex:page>
Class:

public with sharing class DMLStatementOnPageloadController {

public PageReference createAccount(){

Account acc = new Account(name = 'DMLStatementOnPageload');

insert acc ;

return null;

13) Approval step is already created and it is active now. I want to add one more step. How do I do it?
We can't make any changes once the approval process is active. We need to create a new approval
process.

14) Scenario where recursive workflow can occur.


Lets assume an object Test__c has three fields Field1__c, Field2__c and Field3__c. Whenever, any field is
updated, workflow will get triggered which will update a field, Field1__c. Since a field is updated, again a
workflow will get triggered and it in this way workflow will keep on executing.

15) What is @future and what parameters can be passed to it?


A future method runs in the background, asynchronously. You can call a future method for executing
long-running operations, such as callouts to external Web services or any operation you’d like to run in its
own thread, on its own time. You can also make use of future methods to isolate DML operations on
different sObject types to prevent the mixed DML error.
The specified parameters must be primitive data types, arrays of primitive data types, or collections of
primitive data types.

16) Can we call @future in Triggers?


Yes, we can call, Create Apex Handler class and create a future mathod. Same method you can call from
trigger.

17) Explain Schedule Apex


The Apex Scheduler lets you delay execution so that you can run Apex classes at a specified time. This is
ideal for daily or weekly maintenance tasks using Batch Apex. To take advantage of the scheduler, write
an Apex class that implements the Schedulable interface, and then schedule it for execution on a specific
schedule.

Syntax:
global class SomeClass implements Schedulable {
global void execute(SchedulableContext ctx) {
// Write your code here
}
}

18) What is permission set?


We all know that a single profile can be given to more than one person. In case, one of the user needs a
special permission to view some object. If we make changes in the profile, it will be available to everyone
who are associated with that profile. Therefore, we create a permission set which is like an additional
access given to particular user without changing the profile.

19) Explain different types of Reports available in salesforce.


There are four types of Reports available in salesforce:

Tabular Reports:Tabular reports are the simplest and fastest way to look at your data. Similar to a
spreadsheet, they consist simply of an ordered set of fields in columns, with each matching record listed
in a row. While easy to set up, they can't be used to create groups of data and there are limits to how you
can use them in dashboards. Consequently, they're often best used for tasks like generating a mailing list.

Summary Reports: Summary reports are similar to tabular reports, but also allow users to group rows of
data, view subtotals, and create charts. These will take you a bit more time to set up, but summary
reports give us many more options for organizing the data, and are great for use in dashboards.

Matrix Reports: Matrix reports allow you to group records both by row and by column. These reports are
the most time-consuming to set up, but they also provide the most detailed view of our data. Like
summary reports, matrix reports can have graphs and be used in dashboards

Joined Reports:Joined reports let you create different views of data from multiple report types. In a
joined report, data is organized in blocks. Each block acts like a “sub-report,” with its own fields, columns,
sorting, and filtering. You can add a chart to a joined report.

20) Explain OWD.


Org-wide defaults(OWD) specify the baseline level of access that the most restricted user should have.
Use org-wide defaults to lock down your data, and then use the other record-level security and sharing
tools (role hierarchies, sharing rules, and manual sharing) to open up the data to users who need it.

You might also like