Using point and click approach, we can configure the functionalities.
1. What is Track Field History?
While creating the object, we can enable 'Track Field History'.
If, we enable 'Track Field History' user can see 'Set History Tracking' button under 'Custom Fields & Relationships' section which is available on the object detail page.
By clicking on 'Set History Tracking' button, we can enable tracking for the fields which ever we want.
To see the object history, go to object's record layout and add Object Name History related list to the layout.
Whenever, user changes field value from one value to another value, it will show the history of the field in 'Object History' related list.
2. What are the Activities in Salesforce?
To create the Activities, while creating the object, we should check for 'Allow Activities' check box then user can add open Activities and Activity History related lists on the Object layout. There are two types of activities -
Task: Task is nothing but work assigned to a particular person, it doesn't have certain time limit.
Event: It has certain time limit in that time only all persons should assemble after the time limit over, event will get complete.
- Once event or task status changed to 'Completed' then we can see those records under Activity History Related List.
3. How to Rename the tab?
Tab name will be decided based on the Plural Label of the custom object, to rename go to corresponding object detail page and rename the plural label.
4. How to display multiple columns after clicking on the tab?
Click on the tab(Which should be realted to any of the custom/standard object) > Expand Force.com Quick Access Menu > Edit Columns > Move the needed fields from Available Fields to Selected Fields. > Click on Save > User should be able to see multiple columns. (OR)
Click on Setup > Create > Objects > Select the corresponding object link > Under Search Layouts section > Click Edit which should be left to Object Tab > Move the needed fields from Available Fields to Selected Fields. > Click on Save > User should be able to see multiple columns.
5. What is the difference between ISBLANK() AND ISNULL()?
ISNULL() works only for number data type fieds, if we don't populate with value for number fields it will return true.
ISNULL() won't support TEXT data type fields because text fields never become null.
ISBLANK() supports both number as well as text data types.
6. What is dependent picklist?
In some scenario's, we should be able to control one of the field(Dependent field) from another field(Controlling field), example If we select Country(Controlling field) as US then City(Dependent Field) should display only US cities.
We can use checkbox data type fields also while creating dependent picklist (Note: Checkbox should be always controlling field)
We can use multi-select data type fields also while creating dependent picklist (Note: multi-select data type field should be always dependent field)
8. What is the difference between 15 digit and 18 digit id in Salesforce?
In Salesforce, whenever user create any component (Object, field, tab etc...) or record then salesforce will generate an unique id with which user can identify the record or component.
After creating the record, in the URL user can see the id of the record which is of 15 digits length.
Through user interface user always see 15 digit id which is Cases-Sensitive
.
If the user query the existing records from the database through API (Either from Query Tool or from a program), it will always return 18 digit id which is Case-Insensitive.
Last 3 digits of the 18 digit represents checksum of the capitalization of 15 digit id.
Based on the first 3 digits user can identify the object of the record.
All the records belongs to same object will contain same firt 3 digits.
9. What is Record Type?
For an object based on the Record Type, we can show different fields and different picklist values by assigning different page layouts for the record types and profiles.
After creating the record type, on the record type detail page user can see all the picklist data type fields, user can edit the picklist and decide which values should display for this particular record type.
10. What is the difference between detail page and edit page?
Whenever user try to create a new record or edit an existing record user can input the values for the fields, this page is nothing but edit page.
After creating a new record or editing an existing record, user can see the information of the record, this page is nothing but detail page.
11. What is out of box functionality?
Within the sfdc standered functionality (no need to code).
12. What are the type of tabs?
Custom tabs (create for objects)
Web tabs (create to display a website)
Visual force tabs (create to display the visual force page)
13. What is validation rule?
While creating or modifying the record based on the certain conditions we can display error messages on top of the page or below to the filed.
14. There are two fields, if the user populate two field values if we combine those values uniqueness should be maintained, how to achieve this without coding?
Create a unique text field and update the field from workflow rule (use formula to update by combining two field values), after the update again all the system validations will be performed so error will be displayed.
16. For which data type we can enable external id?
text, number, auto number, email.
17. What is list view?
After clicking on the tab on the top of the page we can see views, by default we can see the value called ‘all’. If we click on ‘Go’ beside that all we can see all the records of that object. If we want we can create new views. While creating the view we can give the filter conditions so that based on the filter condition only we can see the records.
18. What is Inline editing?
On the detail page without clicking on edit button we can edit particular field if it is not read-only.
19. How to disable Inline editing?
To enable or disable Inline editing follow the below navigation -
Setup--> Customise--> User Interface--> Enable Inline Editing
20. What is Enhanced list view?
In list views we can modify multiple records at a time using Enhanced list views
Note: To modify multiple records, all the records should belong to same record type in the list view otherwise we cannot modify.
21. What is search layout?
Whenever we click on a tab or we click on a lookup icon or search for a record we see only one standard field by default, to enable remaining fields -
To show multiple fields for the records which display under a tab, on object detail page > under Search layouts edit tab and add required fields.
To show multiple fields for the records which display when we click on lookup of a field, on object detail page > under Search layouts edit Lookup Dialogs and add required fields.
To show multiple fields for the records which display when we search for the records, on object detail page > under Search layouts edit Search Results and add required fields.
22. What is mini page layout and how to enable?
For lookup fields on record detail page we see a link, whenever we put cursor on that link we see a popup window which displays few fields. To control the fields visibility, on that look up field parent object page layout we see a mini page layout in that we can control.
23. What is lead process?
To control the picklist values of the status field on the lead object we should create lead process.
Without selecting the lead process we can't create the record type for lead object
24. What is sales process?
To control the picklist values of the stage field on the opportunity object we should create sales process.
Without selecting the sales process we can't create the record type for opportunity object
25. What is Support process?
To control the picklist values of the status field on the case object we should create support process.
Without selecting the support process we can't create the record type for case object
26. What is web-to-lead?
On lead object we can generate the HTML code by selecting lead fields and by mentioning return URL from web-to-lead option. The generated HTML code can be hosted in any of the website. Upon entering the information in those fields and clicking on submit button that information will be saved into lead object of the Salesforce.
27. What is Queue?
In queue we can add group of users and we can assign the objects to the Queue. After creating the queue one of the list view automatically created on the objects which are selected for the queue. We can assign this queue as the owner of the records (objects which are selected for this queue).
Later users who are part of that queue can claim the ownership by navigating to list view corresponding to the queue. In that list view users who are part of the queue can select the record and click on accept button so that record ownership will be transferred from queue to accepted person.
28. What is public group?
We can add set of random users in the public group. We can't assign public group as an owner of the record. In manual sharing, sharing rules and in list views we can use public group.
29. What are the Assignment rules?
On lead and case objects we can create the Assignment rules. Whenever any record is submitted for lead/case if specified condition in the Assignment rule satisfied based on that we can decide the owner of the case/lead.
Note: While submitting case/lead we should check for 'Assign using active assignment rule' checkbox which will display under Optional section.
30. What are Auto-Response Rules?
On lead and case objects we can create the Auto-Response Rules. Whenever any record is submitted for lead/case if specified condition in the Auto-Response Rules satisfied based on that we can decide the email format which should send as auto response.
31. What are the Escalation rules?
On case object we can create Escalation rule. Based on the priority we can send escalation mails.
Next Question to be added
answer
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 -
Log in as a user to whom you want to enable Log in access.
At top right corner click on name (Which should be left to Setup) > My Settings
User should be able to see user's personal set up page.
Left side, click on Personal Information > Grant Account Login Access
User should be able to see Grant Account Login Access page
In Access Duration column select '1 Year' for all the records and click on 'Save' button.
Log out and Log in as any other user in the organization then click on Manage Users > Users.
User should be able to see list of records and verify the user to whom we enabled the Grant Account Login Access
User should be able to see the Login link beside Edit link.
Click on Login then user should be able to login as that user mode
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.
Click on Logout
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)?
OWD is the default access level on records for any object in sales force.
For custom objects we can see below access levels -
Private
Public Read only
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.
REAL WORLD
Example : A User does not have access to Account Object - What would you do?
Solution 1: Check his Profile and Add Account Object to his profile -
but downside is everyone using this profile will have access to this object.
Solution 2: Create a PermissionSet (with just Account Obeject) and assign it to the user
Solution 2: Sharing Rules. (if he wants a particular record)
Example : Account Object has OWD Setting as Private - What would you do to grant access?
Create a PermissionSet and assign it to the user
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.
Import Wizard and Data Loader
To process bulk records.
1. What is Import wizard?
Import wizard is a web based tool to process bulk records.
With import wizard we can process maximum of 50,000 records.
In import wizard we can't see few objects (ex: if there is masterdetail relationship between two objects then child object we can't see).
2. What is Data Loader?
Data Loader is a stand-alone tool to process bulk records. With Dataloader we can process maximum of 5 million records. Most of the time we use only Dataloader. Default batch size of the Dataloader is 200.
3. Which operations we can perform on dataloader?
Insert (Inserting brand new records, no need of ID)
Update (Updating the existing records based on the record ID)
Upsert (To Upsert we should have one external ID field on the object, based on the external id field if the value already exists it will update, if doesn't exist then it will insert)
Delete (Delete the records based on the id provided, to delete we need only id, deleted records can be found in recycle bin)
Hard delete (Delete the records based on the id provided, to delete we need only id, deleted records can't be found in recycle bin, Note: If we enable bulk API in data loader settings then only we can perform Hard delete.)
Export (From any object we can export records based on the SOQL query, Note: We can't export deleted records which are there in the recycle bin)
Export all (From any object we can export records based on the SOQL query, Note: Using Export all we can export deleted records which are there in the recycle bin also)
4. Data loader or Import wizard supports which file format?
.CSV (Comma Separated Values)
5. What is the filed mapping file format of the data loader?
.SDL
6. How to insert null values into dataloader?
In dataloader settings we should enable 'insert null values' checkbox otherwise we can't insert null values.
7. What is external ID?
Suppose we have account table in Salesforce and account table outside of the Salesforce (ex: .csv file, sql database). In Salesforce all the records can be identified with record id and outside of the Salesforce we can't recognize records with Salesforce id that is the reason to compare outside table and salesforce table in Salesforce for one of the field we have to enable external ID (we can enable external id for text, number, auto number and email). If we enable external id we can compare that particular column with the column which is available in external table. While comparing if the both column values are same then it will update otherwise it will insert.
8. Maximum batch size of data loader?
10,000 records and minimum 1 record.
9. What is default batch size if we enable bulk API?
2,000 records.
Workflows and Approvals
To perform the automated actions.
1. What are the different kinds of evaluation criteria’s (events)?
Created
Created and everytime edited to meet the criteria
Created and edited to subsequently meet the criteria
2. What is the difference between Created and everytime edited to meet the criteria and Created and edited to subsequently meet the criteria?
If we select 'Created and everytime edited to meet the criteria' whenever we create a record or edit a record if the criteria of the workflow rule meets then it will trigger every time.
If we select 'Created and edited to subsequently meet the criteria' -
While creating the record criteria meets so that workflow will fire and while editing the record again criteria meets workflow won't fire (meeting the criteria to meeting the criteria)
While creating the record criteria doesn't meet so workflow won't fire and while editing the record workflow criteria meets then workflow will fire (not meeting the criteria to meeting the criteria)
Conclusion: Previous state of record should be not meeting criteria and current state of record should be meeting the criteria then only in current state workflow will fire.
3. What are the types of rule criteria’s?
Criteria meet (field - operator - value, if there are multiple criteria’s then in filter criteria we can give conditions like ( 1 or 2) and 3, field to field comparison is not possible, we can't fetch the previous state information of the field )
Formula evaluated (we can write formulas with this we can do field to field comparison and we can fetch previous state value of the record)
4. What is immediate workflow action?
The action which will be performed immediately after the record criteria meets.
5. What is time dependent workflow action?
The action which will be performed in future based on the any of the date field. To create time dependent workflow action we should create one time trigger. in time trigger we can give either days or hours with the maximum of 999 value and we can select either before or after.
6. For which event we can't create time dependent workflow action?
Created and everytime edited to meet the criteria.
7. What are the different kinds of workflow actions?
New field update (we can update a field of the same object or the fields of the parent objects which are at master side in master-detail relationship, only for master-detail parent objects we can update the field and for lookup we can't update)
New email alert (we can send emails if the criteria meets)
New task (we can create new task)
New outbound Message (we can make a callout)
8. What are the types of email templates?
Text
HTML (with letter head)
Custom HTML (without letter head)
Visual Force
9. There is a timebased workflow which will update one of the fields if the criteria meet.
User submits the record with valid criteria, workflow triggered so that the field update is queued in the 'time based flow' queue which will fire after one day.
If the user modifies the record which is submitted before the scheduled date, after modification, a record criterion is not meeting. Whether the field will be updated or not in schedule date?
It won't trigger in the schedule date because if we modify the record to not meeting criteria that queued field update will be removed from the 'time based flow' queue.
10. For the same scenario explained in the above question what happens when we deactivate or modify the criteria of the workflow to different criteria? Whether the field will be updated or not in schedule date?
Yes, It will trigger in scheduled date.
11. Scenario: There are two workflow rules on the same object say namely wf1 and wf2. If wf1 fires then a field will be updated on the same object, if the field updated and due to this wf2 criteria meets then what will happen, wf2 will fire or not?
It won't fire. To fire wf2 we should enable 'Re-evaluate Workflow Rules' checkbox of the field update which is there in wf1.
12. What is recursive workflow rule? How to avoid recursive workflow rules?
Whenever we 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 entery criteria of those workflow rules satisfied.
Incase, in other workflow rules also if we 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.
13. What is Approval Process?
If the criteria of the record meets then by clicking on submit for Approval button user can submit the record for approval (Note: Approval history related list should be displayed on the record detail page)
14. How to configure Approval Process?
Before creating the Approval Process we should select the object after that we should follow below steps -
Give the Approval Process name
Give the criteria of the Approval Process
Select the email template (If we don't select any email template salesforce by default send an email notification to the target approver else with our selected email template target approver will be notified)
Select the users who can submit for the approval (If we do not select any user by default all the users who can access to that record can submit)
Select the user to whom record should be submitted
Initial submission actions ( after submitting the record for approval immediately whatever the actions included in the initial submission actions section will be triggered)
Approval Steps (we can add multiple steps)
For each and every step we can see 'Approval actions' and 'rejection actions' sections where we can add actions to be performed
If the Approver approves the record then actions which are under 'approval actions' section will be triggered
Final approval actions section (If all the steps approved then actions which are under 'final approval actions' section will be triggered)
Final rejection actions section (If any one of the step rejected then actions which are under 'final rejection actions' section will be triggered)
Recall approval actions ( After submitting record for approval if you want to revoke we click on recall approval action on the detail page, after clicking on that button actions which are under recall approval actions section will be triggered )
15. Scenario: After activating the approval process, I want to add one more step. Is it possible?
It’s not possible, to add one more step deactivate the approval process and clone the deactivated approval process and add the new steps.
Reports and Dashboards
To summarize the information.
1. What is Report?
To summarize the information of an object we use reports.
2. What are the types of Reports?
Tabular (Displays records just like a table)
Summary (we can summarize the information based on certain fields)
Matrix (we can summarize the information in two dimensional manner, both rows and columns)
Join (we can summarize information in different blocks on the same object and the related objects)
3. How many blocks we can create for join reports?
5 blocks.
4. How many maximum groupings we can do for summary, matrix and join reports?
3 groupings
5. What is bucketing in reports?
Bucket field in Reports is used to group values to the name we specify.
6. How many records we can display on page for a report?
We can display up to 2000 records on a page. If more records are there to display we cannot see those through user interface. If you export the records to a excel sheet then you can export up to to 50000 records.
Do you have any queries mail me at: srinu@srinusfdc.com
6. There is a Queue with name MyQueue. How to query it using SOQL query from the database?
Queues will store in Group object. To query for MyQueue from the database using SOQL, we should use the following syntax -
Group grp = [select Id, Name from Group where Name = 'MyQueue' and Type = 'Queue' Limit 1];
Apex Triggers
Questions on Apex Triggers.
1. What are the trigger events?
Before Mode: Before the record is saving into the database, it will fire.
After Mode: After the record is saved into the database (doesn't commit at this point of time), it will fire.
Before
After
before insert
after insert
before update
after update
before delete
after delete
-
after undelete
Note: before undelete event is not available.
2. What are the trigger context variables?
To capture the runtime information we use trigger context variables.
Below context variables will return either true or false.
Trigger.isBefore (returns true if the trigger context is Before Mode)
Trigger.isAfter (returns true if the trigger context is After Mode)
Trigger.isInsert (returns true if the trigger context is Insert)
Trigger.isUpdate (returns true if the trigger context is Update)
Trigger.isDelete (returns true if the trigger context is Delete)
Trigger.isUndelete (returns true if the trigger context is Undelete)
Trigger.isExecuting (returns true if the apex class method is getting call from Apex Trigger)
Below context variables will store records at runtime.
trigger.old (stores history (old versions) of the records.)
trigger.oldMap (stores history (old versions) of the records along with id.)
trigger.new (stores new version of the records.)
trigger.newMap (stores new version of the records along with id.)
3. Availability of trigger.old and trigger.new for the different trigger events?
Apex Trigger Collections availability for the different events -
Events
trigger.old
trigger.oldMap
trigger.new
trigger.newMap
before insert
✘
✘
✔
✘
after insert
✘
✘
✔
✔
before update
✔
✔
✔
✔
after update
✔
✔
✔
✔
before delete
✔
✔
✘
✘
after delete
✔
✔
✘
✘
after undelete
✘
✘
✔
✔
4. Read/Write accessibility of trigger.old and trigger.new?
Read/Write access over the trigger collections on different events -
Events
trigger.old
trigger.oldMap
trigger.new
trigger.newMap
before insert
NA
NA
Read/Write
NA
after insert
NA
NA
Read Only
Read Only
before update
Read Only
Read Only
Read/Write
Read/Write
after update
Read Only
Read Only
Read Only
Read Only
before delete
Read Only
Read Only
NA
NA
after delete
Read Only
Read Only
NA
NA
after undelete
NA
NA
Read Only
Read Only
5. When to use before triggers and when to use after triggers?
Before Triggers
To perform the validations we should use before triggers.
If you are updating any field on the same object on which you are writing the trigger and no need to explicitly include the DML statemetns (already due to DML operation only trigger fire and it is still in progress at this point of time.)
After Triggers
If you are dealing with relationship records and if you need record id in these situations we should use after trigger (in before insert record doesn't contain the record id).
6. For the same event if there are multiple triggers on the object, how to control the order of execution?
We cannot control the order of execution in this situation. It is recommended to have only one trigger per one object.
Note: We can keep the logic of the apex trigger in an apex class and can invoke from that class.
7. What are the recursive triggers and how to avoid?
If we perform update operation on the record in after update event logic recursive triggers will arise.
Using static boolean variable in an apex class (we should not keep static boolean variable inside of the trigger) we can avoid recursive triggers.
8. What is MIXED-DML-OPERATION error and how to avoid?
If we perform DML operation on standard/custom object and global objects(User, UserRole, Group, GroupMember, Permission Set, etc...) in same transaction this error will come.
To avoid this error, we should perform DML operation on standard/custom object records in a different transaction.
In general all the apex classes and apex triggers execute synchronously (execute immediately).
if we perform DML operation on standard/custom object records asynchronously (execute in future context), we can avoid MIXED-DML-OPERATION error.
To execute logic asynchronously keep the logic in an apex method (in a separate apex class, not in same apex trigger) which is decorated with @future annotation.
see the below example -
Note: To analyse the code copy it and paste it in notepad for the convenience.
public class TriggerUtility {
/*
1. Following future method execute asynchronously (whenever server is free it will execute in future context).
2. We should not declare @future method in Apex Trigger.
3. @future method should be always static.
4. @future method accepts only primitive data types (Integer, String, Boolean, Date, etc...) as parameters and it won't accept
non-primitive data types (sObject,Custom Objects and standard Objects etc.. ) as parameters.
5. @future method should not contain return type. Always it should be void.
6. From an apex trigger we can make only make asynchronous call outs. To make call out we should include "callout = true" beside the future @annotation.
7. We cannot perform synchronous call outs from Apex Trigger.
*/
//Below is the example for the future method -
@future(callout = true)
public static void processAsync(primitive parameters) {
//Logic to insert/update the standard/custom object.
}
}
9. Following Custom Objects are available in the organization -
ChildObject__c
ParentObject__c
Click to see the full question.
Relationship between ChildObject__c and ParentObject__c objects is Lookup relationship.
In case of lookup relationship if we delete the parent object record in child object only the relationship field value will be removed (child records won't be deleted).
But client has a requirement to delete the child object records. How to achieve this?
Write an apex trigger to achieve this functionality.
We should take before delete event. If we take after delete relationship will broke up b/w parent and child object records.
Trigger ParentTrigger on ParentObject__c(before delete) {
/*
Note:
- For delete events only trigger.old and triggger.oldMap will be available.
- trigger.old holds old versions of the records but if we mention that in SOQL query salesforce will automatically convert those records into ids.
*/
List childLst = [select id, Parent_Object__c from ChildObject__c where Parent_Object__c in: trigger.old];
delete childLst;
}
10. What is the order of execution in salesforce?
We are creating validation rules, workflow rules, assignment rules, auto-responsive rules, escalation ruels and apex triggers etc..
If the condition is same for all the rules which will execute first and which will execute next, for this salesforce provide the order.
Order of execution in salesforce -
Order of execution in Salesforce:
Prepare the record for insert/update operation.
It will replace all the old field values with new field values.
If the request is coming form UI all the system validations will execute -
DataType
Length
Required
unique
pageLayot level validations
before triggers
Custom Validations and again system validation rules will fire (pageLayot level validations won't fire at this point of time).
record will be saved into the database but doesn't not commit.
after triggers.
assignment rules.
auto-responsive rules.
Workflow Rules
incase of Workflow Rule Field updates again before triggers and after triggers fire one more time. System validation ruels for duplicate chcek.
Escalatoin Rules.
Rollup-Summary fields will be calculated.
Grant parent Rollup-Summary fields will be calculated.
Criteria base sharing evaluation.
Record will be commited into the database.
Post Commit logic (Sending emails).
11. There is a validation rule which will fire if amount = 100 and will display the error message. There is a workflow rule which will fire if amount > 100 and will update amount field to 100. One of user saved the record by giving value as 1000. what will the value of the amount field.
Validation rules will fire first then workflow rules will fire. So, the answer is 100 (Even though there is a validation rule because of the workflow rule it will accept 100 in the amount field).
12. There is a before trigger which will fire if amount = 100 and will display the error message. There is a workflow rule which will fire if amount > 100 and will update amount field to 100. One of user saved the record by giving value as 1000. what will the value of the amount field.
It will throw the validation error because after the workflow field update before triggers fire one more time.
Batch Apex
Questions on Batch Apex.
1. What is Batch Apex?
We can call the apex code by creating object for the class (or) if the variables or methods are static then we can call with class name.
Apex Code in the trigger will execute automatically for the DML operations.
If you want to execute apex code on a specific time then we should write batch class.
With Batch Apex we can process maximum of 50 million records.
Batch Apex is asynchronous (execute in future context).
While writing the batch class we should inherit Database.Batchable interface.
Database is a built in global class which contains inner global interface.
2. What are the Batch Apex methods?
Since we are inheriting Database.Batchable interface we should implement all the method prototypes declared in the interface.
We should implement the following global methods -
start: It will prepare the records to process and execute only one time.
execute: It will take the records prepared in start method and split those records into batches and it will execute multiple times. For example if the start method is returning 1000 records then execute method executes 5 times if you don't mention the batch size (Default Batch Size is: 200). Maximum batch size is: 2000.
finish: We can perform post commit logic like sending emails with the success or error information. It will execute only one time.
Batch Class Syntax:
//Database is Class provided by Salesforce.
//Batchable is an global interface which is inside of the Database class.
//Batchable include 3 method prototypes: 1. start 2. execute 3. finish
//start and finish methods will execute only one time.
//execute method executes multiple times.
global class BatchUsage implements Database.Batchable , Database.Stateful {
//at a time we can inherit multiple interfaces but we cannot inherit multiple classes.
//By default batch class is stateless (variable info. store in one method cannot be remembered in other method),
//to make it stateful we should inherit Database.Stateful interface.
String name = '';
global Database.queryLocator start(Database.BatchableContext bc) {
//From asynchronous to asynchronous we cannot call
//(from batch class we cannot call future mehthod vice versa.).
name += 'start';
system.debug('@@@Start Method: '+name);
//Collects the records to process. It will forward these records to execute method.
//If we use Iterable as return type for this start method it can hold
//max. of 50k records only.
//If we use Database.queryLocator as return type for this start method it can hold
//max. of 50 million records.
return Database.getQueryLocator('select id, name, Location__c from Department__c where Location__c = \'\'');
}
global void execute(Database.BatchableContext bc, LIST sObjLst) {
name += 'execute';
system.debug('@@@Execute Method: '+name);
//Split the records forwarded by start method into batches.
//Default batch size is: 200.
//Max. batch size is: 2000.
List depUPdLst = new List();
for(SObject sObj: sObjLst) {
Department__c dept = (Department__c) sObj;//Type Casting.
dept.Location__c = 'Bangalore';
depUPdLst.add(dept);
}
if(depUPdLst.size() > 0)
update depUPdLst;
}
global void finish(Database.BatchableContext bc) {
name += 'finish';
system.debug('@@@Finish Method: '+name);
//Post Commit logic like sending emails for the success or failures of the batches.
AsyncApexJob a = [select id, Status, NumberOfErrors, JobItemsProcessed,
TotalJobItems, CreatedBy.Email from AsyncApexJob where id =: bc.getJobId()];
Messaging.singleEmailMessage mail = new Messaging.singleEmailMessage();
mail.setToAddresses(new String[]{a.CreatedBy.Email});
mail.setSubject('Batch Class Result');
mail.setHtmlBody('The batch Apex job processed ' + '' + a.TotalJobItems + '' +
' batches with '+ '' + a.NumberOfErrors + '' + ' failures.');
//sendEmail methods
Messaging.sendEmail(new Messaging.singleEmailMessage[]{mail});
/*** Scheduling in minutes or hours ***/
/*//Create object for schedulable class
SchedulableUsage su = new SchedulableUsage();
//Preparing chron_exp
Datetime sysTime = System.now();
sysTime = sysTime.addminutes(6);
String chron_exp = '' + sysTime.second() + ' ' + sysTime.minute() + ' ' +
sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();
System.schedule('Dep Update'+sysTime.getTime(),chron_exp, su);*/
}
}
3. How to schedule batch apex?
To schedule the batch class we should write a separate class by implementing Schedulable interface.
After writing the above mentioned class to schedule navigate to: Develop> Apex Classes> Schedule Apex.
By clicking on Schedule Apex button we can schedule the batch class through user interface.
Note: Through user interface we cannot schedule in hours/minutes.
Schedulable Class Syntax:
global class SchedulableUsage implements Schedulable {
global void execute(SchedulableContext sc) {
BatchUsage bu = new BatchUsage();
//Database.executeBatch(bu);//Default Batch Size is: 200.
Database.executeBatch(bu,1500);//Max. Batch Size is: 2000.
}
}
4. How to schedule batch apex in minutes/hours?
To schedule the batch class in minutes/hours, in the finish method we should use System.schedule method which will take 3 parameters Job Name, Chrone Expression and schedulable class instance name respectively.
5. How to maintain the state between the methods of batch class?
By default batch class is stateless (variable value which is stored in one method cannot be remembered in another method).
To maintain the state for the batch class, we should inherit Database.Stateful interface.
Scenario: In a set list of emails are stored in execute method. In the finish method that set is not having any emails. What is the reason?
Answer: By default batch class is stateless. Emails which are added to set can be remembered only in execute method. If we try to access the set in finish method you won't see those emails. In finish method if you want to access those emails of that set we should inherit the interface called Database.Stateful.
6. Is it possible to call batch class from one more batch class?
Yes it is possible, starting with Apex saved using Salesforce API version 26.0, you can call Database.executeBatch or System.scheduleBatch from the finish method. This enables you to start or schedule a new batch job when the current batch job finishes.
For previous versions, you can’t call Database.executeBatch or System.scheduleBatch from any batch Apex method. Note that the version used is the version of the running batch class that starts or schedules another batch job. If the finish method in the running batch class calls a method in a helper class to start the batch job, the Salesforce API version of the helper class doesn’t matter.
7. Is it possible to call future method from a batch class?
We cannot call one asynchronous process from another asynchronous process.
Since @future method and Batch Class both are asynchronous we cannot call future method from batch class or we cannot call batch class from the future method.
8. How to cover the code for a batch class?
To cover the code for the batch class we should call the batch class from the inside of the Test.startTest() and Test.stopTest().
Test.startTest();
//Call the batch class from here.
Test.stopTest();
9. How many batch jobs can be active/queued at a time?
Up to 5 batch jobs can be queued or active.
10. Is it possbile to write batch class and schedulable class in a same class?
By implementing Database.Batchable and Schedulable interfaces we can implement the methods in a same class.
Though it is possible it is not recommended to write like this.
Test Classes
Questions on Test Classes.
1. What is the purpose of writing the test class?
After developing an apex class or apex trigger we should write the unit tests and ensure that we are able to execute at least 75% of the lines of code.
If you are moving the code from sandbox to sandbox regarding code coverage you won't face any issue.
If you are moving the code from sandbox to production, you need to include all the test classes at the time of deployment and salesforce will run all the test classes which you included for the deployment as well as test classes which are already present in production, if the code coverage is less than 75% deployment will fail.
2. Is it possible to write test code inside of an apex class or apex trigger?
we cannot write test code (test methods) inside of the apex trigger.
From API Version 28.0, we cannot write the test methods inside of an apex class which is not decorated with @isTest.
We can write test methods only in a class which is decorated with @isTest.
Note: We have a governor limit for the overall Apex Code size of the organization which is of 3 MB. If we decorate a class with @isTest annotation Apex Code Size governor limit will be bypassed.
By default test class cannot recognize the existing data in the database.
if you mention @isTest(seeAllData = true) then test class can recognize the existing data in the database.
See the below examples -
From a List Custom Settings we cannot fetch the existing data without seeAllData = true in test class.
Suppose you have a custom object called 'CustomObject__c' and it contains many records, we cannot fetch the existing data without seeAllData = true in test class.
Note: It is not recommended to use seeAllData = true for a test class. Based on the existing data in database code coverage will impact.
5. What is the purpose of Test.startTest() and Test.stopTest()?
Test.startTest() and Test.stopTest() maintains fresh set of governor limits. Assume that you are consuming 99 SOQL queries outside of Test.startTest() and Test.stopTest() then if you include any SOQL inside of Test.startTest() and Test.stopTest() count will start from 1.
Per testMethod we can use Test.startTest() and Test.stopTest() only for one time.
To execute asynchronous methods synchronously we can call those methods from inside of Test.startTest() and Test.stopTest().
6. What is the purpose of system.runAs()?
By default test class runs in System Mode. If you want to execute a piece of code in a certain user context then we can use system.runAs(UserInstance). For more details refer 2nd question in visualforce category.
To avoid MIXED-DML-OPERATION error we can include DML statements inside of system.runAs(), still the error persists keep DML statements inside of Test.startTest() and Test.stopTest().
7. What are the assert statements?
What is the purpose?
To compare Actual value and Expected value we use assert statements.
Types of assert statements
system.assertEquals(val1,val2): If both val1 and val2 are same then test class run successfully otherwise test class will fail.
system.assertNotEquals(val1,val2): If both val1 and val2 are not same then test class run successfully otherwise test class will fail.
system.assertEquals(val1> val2): If the condition satisfied then test class run successfully otherwise test class will fail.
8. What is the purpose of Test.isRunningTest()?
Sometimes we cannot satisfy certain if conditions for the apex classes, in those situations on those if conditions we can add Test.isRunningTest separated with or condition. Example: if(condition || Test.isRunningTest())
9. What is the purpose of @TestVisible?
Sometimes in test classes we need to access a variable from Apex Class, if it is private we cannot access for that we will replace private with public. for this reason we are compromising the security. To avoid this before the private variables in apex class we can include @TestVisible so that even though variable is private we can access from the test class.
10. What are the test class best approaches?
We should not depend on the existing data in the database. We should create the test data for all the possible scenarios.Note: Profiles and recordTypes cannot be created programmatically, we can query from the database. For the remaining objects including users we should create the test data.
While testing apex triggers and batch classes, we should do bulk testing at least with 200 records.
We should test for all the positive and negative scenarios.
Web Services
Questions on Web Services.
1. What are the types of Web Services?
preparing...
2. To be added?
preparing...
Do you have any queries mail me at: srinu@srinusfdc.com
Visualforce Basics
Questions on Visualforce Basics
1. Visualforce Basics.
Previously Visualforce Pages were not there, instead S-Controls were there.
S-controls have been superseded by Visualforce pages. Organizations that haven’t previously used s-controls can’t create them. Existing s-controls are unaffected, and can still be edited.
S-controls: It is a combination of HTML and java script but with this to achieve saelsforce look and feel, it is very difficult and consume lot of tags.
Visualforce: With visualforce we can easily achieve the salesforce look and feel by consuming very few tags.
Browsers (IE, Chrome, Firefox, etc...) can understand only HTML, Visualforce will be converted to HTML before display on the browser by salesforce.
Visualforce page should start with the following syntax -
2. What is the difference between system mode (system context) and user mode (user context)?
System Mode: Current logged in user permissions (Object-level, Field-level, Record-level security) won't be considered. Even though user doesn't has access, it will provide full permissions.
User Mode: Current logged in user permissions (Object-level, Field-level, Record-level security) will be considered.
See the following table -
Component
Default Mode
Apex Class
System Mode
Apex Trigger
System Mode
standardController
User Mode
controller
System Mode
Extensions (standardController)
User Mode
Extensions (controller)
System Mode
Anonymous Block
User Mode
Note: to apply security for Apex Class, we can use with sharing while declaring the class. With sharing will apply only Record-level security. It won't apply Object-level and Field-level security.
3. What are the types of controllers available for the visualforce page?
There are the two types of controllers -
Standard Controller
Custom Controller
Note: on a visualforce page, we can use either standardController (attribute name for Standard Controller) or controller (attribute name for Custom Controller). We cannot refer both at a time.
StandardController -
We can refer any standard object or custom object in this attribute. At a time we can refer only one object and we cannot refer apex class in this attribute.
standardController by default works in user mode.
controller -
We can refer any apex class in this attribute. At a time we can refer only one apex class in this attribute.
controller by default works in system mode.
Other supported attributes for the controllers -
extensions
Standard List Controller
Custom List Controller
extensions -
We can refer this attribute along with standardController or controller attribute.
In extensions attribute, we can refer multiple apex classes. We cannot refer standard/custom objects.
Standard List Controller -
There is no such attribute called standard list controller but in the standardController page if you mention recordsetVar attribute then that page we can call it as standard list controller page.
In recordsetVar attribute we can give any name which will hold the list of records of the object which we mentioned for the standardController.
Custom List Controller -
There is no such attribute called custom list controller but in the controller page if we display multiple records then that page we can call it as custom list controller.
In controller class, we have to query the records from the database to display the records on the page.
4. Following classes are there what will be the priority -
controller="MainClass"
extensions="ClassA,ClassB,ClassC"
click to see the question in detail.
A method with the name save exists in all the classes mentioned above. Which will execute first and what is the order?
First of all it will give priority for the extensions, in case there are multiple classes referred then it will give priority from left to right after that only it will check in main controller (either standardController or controller).
In the above scenario, it will invoke the save method from ClassA.
5. What is View State?
Creation: In a visualforce page, whenever we use form tag then view state will be created for the page.
Purpose: Assume that, we need to display the user input form in 3 different visualforce pages. In first and second pages, user has to fill the information and click on Next button. On the final page, after filling the form if he/she will click on Save button, which ever the information we filled in the first and second pages should be also saved. View state will store the information which is filled in first and second page . To maintain the state of the page, we need view state.
Size: All the variables which we use in controller/extensions classes and expressions which are declared on the page will occupy the space in view state.
Governor Limits: Maximum size of the View State is: 135 KB.
Page Performance:
Whatever the variables information we don't required to maintain the state while navigating to other pages those variables we can decorate with transient keyword which won't occupy space in the view state.
Static variables also won't occupy space in the view state.
It is recommended to use only one form tag. If there are multiple form tags hierarchy of the folder structure increases which will occupy more space.
6. What are the Static Resources?
To store the following kind of files and refer on the visualforce page -
images
javaScript/jQuery
CSS Style Sheets
zip files
Overall size of the static resources per organization: 250 MB
Size of the each static resource file: 5 MB
To refer the static resource on the vf page use: $Resource.FileName
To refer the zipped static resource on the vf page use: URLFOR($Resource.zipname, '/images/FileName.png')
7. What is the defference between Static Resources and Documents?
Please find the following differences -
Static Resources
Documents
Static Resource is cached at server side.
Documents will store in database.
Static Resources can be referred with file name.
Documents should be referred with url.
8. How to display error messages on VF(Visualforce) page?
on a standardController page to display the multiple records we use recordSetVar (without the support of any extensions class).
10. What is the difference between dataTable and pageBlockTable?
dataTable: Display the records without standard salesforce look and feel.
pageBlockTable: Display the records with standard salesforce look and feel.
11. Maximum number of records displayed on the VF page?
1000
12. How to display more records beyond the supported limit on the VF page?
For the page tag we can enable readOnly attribute value as true so that -
Number of query rows will increased from 50000 to 1 million rows.
Number of records displayed on VF page will be increased from 1000 to 10000
13. What is the difference between inputText and inputField?
inputText: Always display the field as text box irrespective of data types (Checkbox, Picklsit, Look up).
inputField: Display automatically according to the fields data types. Note:We cannot refer primitive data types (String etc.) with inputField.
14. What is the difference between outputText and outputField?
outputText: Always display the field value as text irrespective of data types (Currency, Look up, URL etc.).
outputField: Display automatically according to the fields data types. If it is currency then it will append currency symbol while displaying on the page. If it is look up type then it will display as a link.
15. What is pagination and what are the ways to achieve it?
Assume that we need to display 100 records on the page. If the requirement is to display only 10 records at a time -
First: Displays first set of 10 records.
Previous: Displays previous set of 10 records.
Next: Displays next set of 10 records.
Last: Displays last set of 10 records.
We can achieve the above functionality with Pagination. We can achieve the pagination in two ways -
Using standardSetController
Using Limit and Offset keywords in SOQL query.
17. What are the custom labels?
Custom Label is a memory location where we can store the text.
Where to use?
we can refer in below components -
Validation Rules and Formula fields
Apex Classes and Apex Triggers
Visualforce Pages
What is the advantage?
Assume that you are referring a Record Type Name multiple times in an apex class, in future if the client asked to rename the record type then in all the palaces we need change by searching which consume good amount of time. To avoid that if you store the Record Type Name in custom label and refer that custom label in all the places. If you need to change the name in future then you need to change only in that custom label.
Assume that you are displaying an error message on the visualforce page, in future if the client asked to change the error message then it will be a code change. For code change it requires lot of approvals from business which consume lot of time. If you keep the error message in a custom label and refer on the page, in future it won't be a code change, in production directly they can replace the error message in that custom label.
18. What are the Custom Settings?
There are two types of custom settigns -
List Custom Settings
Hierarchy Custom Settings
List custom settings -
List Custom Settings are like custom objects.
We can create the fields and we can store the records.
List Custom Settings records will store in Application Cache memory.
To access List Custom Settings records no need to use SOQL query.
Example: Based on the regions, zip codes should be retrieved. In this case, If you store these records in a custom object every time we need to query from the database. Instead if you store the records in List Custom Settings, without consuming SOQL query we can capture the information from the database.
Hierarchy custom settings -
We can add users and profiles.
After that we can check that a particular/current logged in user is part of this custom settings.
We can refer this in below components -
Validation Rules
Apex Classes and Apex Triggers
Visualforce Pages
19. What is the difference between List Custom Settings and Custom Object?
Please find the below differences -
List Custom Settings
Custom Objects
Stores data in Application Cache memory.
Stores data in database.
No need to use SOQL query to fetch the records.
We need to use SOQL query to fetch the records from the database.
Limited data types are available when compared to Custom Object.
All the data types will be available.
We cannot create validation rules and apex triggers on List Custom Settings.
We can create.
We cannot create tab for List Custom Settings.
We can create.
20. What is the difference between rendered, rerender, renderAs and contentType?
rendered: Accepts true or false. If it is true then component will display on the page, if it is false then it won't display on the page.
rerender: To refresh certain area of a page based on component id.
renderAs: Used in page tag, We can display VF page in PDF format if we give renderAs = "PDF".
contentType: Used in page tag, we can download VF page in MS Word/Excel etc. based on the input to contentType.
21. What is button overriding?
We can override few standard buttons with visualforce pages.
To override standard button with visualforce page, VF page should be of standardController to an object which is related to standard button.
Custom buttons we can override with URL, javaScript or Visualforce.
22. What are the inline visualforce pages?
On a record detail page we can embed visualforce pages.
Assume that you are displaying inline VF page on Account record detail page. VF page should be standardCotnroller to Account Object.
Note: We cannot embed VF page inside of the Edit page.
23. What is the use of immediate attribute?
Whenever we click on Back or Cancel button on a VF page if there are mandatory fields then we will see the error messages saying to populate those field values.
To bypass validations upon clicking on a button/link, we can use immediate attribute.
24. What are the parameters and how many ways we can pass the parameters?
?param1=val1 : parameters should start with ? symbol.
¶m2=val2 : To add multiple parameters, each parameter should be separated with & symbol.
Ways of passing parameters -
From a VF Page: Whenever we click on commandButtton or commandLink or outputLink, we can pass parameters with param tag. See the below example -
click
From pageReference: Upon calling an action method while returning pageReference we can append parameters. See the below example -
PageReference nextpage = new PageReference('/apex/SamplePage');
nextpage.getParameters().put('param1','val1');
nextpage.getParameters().put('param2','val2');
Assume that there are three VF pages which are using the same Apex Class. In this case no need to pass the parameters from one page to other to hold the information.
Assume that there are three VF pages which are using three different Apex Classes. In this case to hold information from one page to other, we should pass teh parameters. Click here for the reference.
25. What is retURL and saveURL?
We cannot override Save button. When you are on record edit page upon clicking on Save button if you want to navigate it to a specific url then we need to append saveURL=someURL parameter to the URL. You will come to this edit page if you click on 'New' or 'Edit' button which can be overriden with VF page, from this page you can pass saveURL parameter to edit page.
When you are on record edit page upon clicking on Cancel button if you want to navigate it to a specific url then we need to append retURL=someURL parameter to the URL.
26. What are the Visualforce Components?
Like VF page we can create visualforce component. Syntax -
Your code here.
We can use only controller and extensions attribute for the VF component. standardController cannot be used.
When to use VF Component?
If you want to reuse the VF page logic.
If the VF page logic is huge and if you want to split into different pieces.
27. What is the order of execution of VF page?
We can request VF page in two ways -
Get Request: Whenever we click on a link or button or directly hitting the url in address bar we can open a VF page.
Do you have any queries mail me at: srinu@srinusfdc.com
Apex Triggers
Scenarios on Apex Triggers.
1. Scenario: Child__c and Parent__c are the two custom objects and the relationship between them is Look-up relationship. click here to see the full question.
Child__c has a look-up relationship with the object Parent__c. In case of look-up relationship, if we delete the parent objects records then in child object only that look-up value will be removed. Here the requirement is whenever user delete the parent records then all the related child records should be deleted (entire record).
* Apex Trigger to delete the related child object records upon
* deleting the parent object record in case of look up
* relationship *
* Author:
* ========
* www.srinusfdc.com
*/
trigger ParentTrigger onParent__c(beforedelete){
/*Assume that parent__c is a field api name( look up to parent object) in child object.*/
delete [select id fromChild__c whereparent__cin: trigger.old];
/*Note: trigger.old will be automatically converted to set of ids
by salesforce (alternative: trigger.oldMap.keyset()).*/
}
/* Description:
* ============
* Apex Trigger to delete the related child object records upon
* deleting the parent object record in case of look up
* relationship *
* Author:
* ========
* www.srinusfdc.com
*/
trigger ParentTrigger on Parent__c (before delete) {
/*Assume that parent__c is a field api name( look up to parent object) in child object.*/
delete [select id from Child__c where parent__c in: trigger.old];
/*Note: trigger.old will be automatically converted to set of ids
by salesforce (alternative: trigger.oldMap.keyset()).*/
}
2. Two objects Parent__c and Child__c are there. Child__c has look up to Parent__c. click here to see the full question ?
Child__c has two fields Amount and quantitiy. In parent display total amount and total quantity of all the related child records.
Solution
Prerequisite
Please follow the below steps to proceed with this example.
S.No
Component
Follow the order as mentioned below to create the components
Configuration
1
Create New App App Label: Sample App Name Sample Note: Enable security for all the profiles.
/***
Steps to execute the above code -
---------------------------------
1. Navigate to: Developer Console > Debug > Open Execute Anonymous Window.
2. Paste the following code snippet -
RemoveWhiteSpace rws = new RemoveWhiteSpace();
system.debug(rws.remvoeWhiteSpaceFromString('Salesforce Interview Questions'));
3. Check for 'Open Log' checkbox.
4. Click on execute
5. Click on 'Debug Only' checkbox
=======================================
You should be able to see the following Output -
--------
SalesforceInterviewQuestions
==================================
Reference:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm#apex_System_String_deleteWhitespace
***/
Program#2: Return a Fibonacci Series (String format) for an Integer input.
/***
Steps to execute the above code -
---------------------------------
1. Navigate to: Developer Console > Debug > Open Execute Anonymous Window.
2. Paste the following code snippet -
Fibonacci fibbo = new Fibonacci();
system.debug(fibbo.getnerateFibbonaci(23));
3. Check for 'Open Log' checkbox.
4. Click on execute
5. Click on 'Debug Only' checkbox
=======================================
You should be able to see the following Output -
--------
Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711
***/
Program#3: Return true/false by checking leap year or not for a give year.
public class LeapYear {
public Boolean isLeapYear(Integer year) {
Boolean isTrue = false;
if ( math.mod(year,400) == 0 || math.mod(year,4) == 0)
/***
Steps to execute the above code -
---------------------------------
1. Navigate to: Developer Console > Debug > Open Execute Anonymous Window.
2. Paste the following code snippet -
LeapYear lepYr = new LeapYear();
system.debug(lepYr.isLeapYear(2004));
3. Check for 'Open Log' checkbox.
4. Click on execute
5. Click on 'Debug Only' checkbox
=======================================
You should be able to see the following Output -
--------
true
/***
Steps to execute the above code -
---------------------------------
1. Navigate to: Developer Console > Debug > Open Execute Anonymous Window.
2. Paste the following code snippet -
SwapNumbers sn = new SwapNumbers();
sn.doNumSwapping(6,13);
3. Check for 'Open Log' checkbox.
4. Click on execute
5. Click on 'Debug Only' checkbox
=======================================
You should be able to see the following Output -
--------
a value: 13
b value: 6
***/
Salesforce Apex Interview Questions
Q1) What is Apex in Salesforce?
Apex is a strongly typed object-oriented programming language.
It allows the developer to execute flows and transaction control statements.
Apex enables developers to add business logic to most system events like button clicks related record updates and visualforce pages.
Q2) What is Apex Programming Language?
1. Integrated: It provides built-in support for DML Calls
2. Inline Salesforce Object Query Language
3. Easy to Use
4.Easy to Test
5. Version
6. Multi Tenant Aware Application
Q3) When Should I Use Apex?
To create Email services
Create web services
Perform complex validation over multiple objects
To create complex business processes that are not supported by workflow.
Create custom transaction logic
Attach custom logic to another operation
Q4) How Does Apex Work?
All Apex programs runs entirely ON-Demand on Force.com Platform.
First the platform application server compiles the code into abstract set of instructions that can be understood by Apex runtime interpreter.
The compile code is stored to metadata.
When the end users triggers the execution of Apex by clicking button or visualforce page the application servers retrieves the compiled instructions from the metadata and send them to runtime interpreter before returning the result.
Q5) What is Apex Email Service?
Email services is an automated process that use Apex classes to process the contents, Headers, Attachments of Inbound Email. Note:
Visualforce email templates cannot be used for mass emails.
We can associate each email services with one or more salesforce generated email address to which the users can send messages for processing.
Q6) What is Map Class in Apex Salesforce?
Map Class Contains methods for the Map collection type.
A Map is collection of key values pairs where each unique key maps to a single value.
Map keys and values can be any data type primitive types, collections, sObjects, users defined types, and built in Apex Types.
For Example, the following table represents a map of countries and currencies
Country(Key)
‘United States’
‘Japan’
;France’
‘England’
‘India’
Currency (Value)
‘Dollar’
‘Yen’
‘Euro’
‘Pound’
‘Rupee’
Q7) What is SOQL?
A query language that allows you to construct simple but powerful query strings and to specify the criteria that should be used to select the data from the platform database. SOQL Stands for Slaesforce Object Query Language.
Q8) What Are The Types of SOQL Statements in SalesForce?
Salesforce Object Query Language is used to query that records from the database.com based on the requirement.
There are 2 types of SOQL Statements.
1. Static SOQL
2. Dynamic SOQL
1.Static SOQL: The oStatic SOQL Statement is written in [] (Array Brackets)
This statements are similar to IINQ(Ion Integrated Query) Example:
String search for =’Jones’;
Contact[] contacts=[select testfield__c, FirstName, LastName from Contact Where Last Name=:search for];
2. Dynamic SOQL:
It is used to refer to the creation of a SOQL string at run time with Apex code.
Dynamic SOQL enables you to create more flexible application.
To create Dynamic SOQL query at run time use Database.Query() method, in one of the following ways.
Return a single sObjects when the query returns a single record.
sObjects s = Database. Query(String_limit_l);
Return a list of sObjects when the query returns more than a single record.
Examples:
Eg1:
String myTestString = ‘TestName’;
List List= Database.Query(SELECT Id FROM MyCustomObject__c WHERE Name = :myTestString);
Eg2:
String resolviedfield L = myvariable.field__c;
List L = Database.Query(‘SELECT Id FROM myCustomObject__c WHERE field__c = ‘+resolvedfield_L);
Q9) What is The Syntax of SOQL Statement?
SELECT field1, field2,.... FROM Object_Type [WHERE condition] Example:
List accountList =
[SELECT ID, Name, FROM Account];
List accountList =
[SELECT ID, Name, FROM Account WHERE annual revenue<10000];
Q10) What is Apex Interface?
Interface is a collection of unimplemented methods. This will specify the signature of the method, types of inputs that we pass the method specifies what type is given as an output. NOTE: Generally the interface methods we give it as global.
Q11) What is Batch Apex in Salesforce?
Batch Apex: Batch Apex allows you to define a single job that can be broken up into manageable chunks, whereas every chunk can be processed separately.
In the Batch Apex it will fetch all the records on which you want to perform the field update and divide them into list of 200 records and on every 200 records operation is performed separately.
This would help us to execute on more than 10,000 records as, it won’t perform an operation on all the records in a single transaction instead it dividing them into Number of subtasks where each subtask may contain the records up to 4000.
Example:
If you need to make a field update of every record of account object in your organization, then we have governing limits that would restrict us from achieving the above task. Reason: In a single transaction we can process only 10,000 records. Now in the above case if we have more than 10,000 records in the organization then we can not perform this field update.
Q12) What is Apex Scheduler?
It will invokes the Apex class to run at specific time.
Anybody who want to schedule their class they have to implement schedulable interface.
Schedule Interface:
The class that implements this interface can be scheduled to run at different intervals. This interface has several methods they are
Public void execute(schedulablecontext sc)
Example:
Public class mySchedule implements schedulable
{
Public void execute(schedulablecontext sc)
{
Account a = new Account(Name = ‘Faraz’)
Insert a;
}
}
Q13) What is the Apex Trigger in Salesforce?
Trigger is a Apex Code that executes before or after.
The following types of DML Operation:
Q14) What are The Types of Apex Triggers in Salesforce?
Triggers Are divided into 2 types
1. Before Triggers
2. After Triggers
1. Before Triggers:
Before Triggers can be used to update or validate values of a record before they are saved to the database. 2. After Triggers:
After Triggers Before Triggers can be used to access field values of the records that are the stored in the database and use this values to make changes in other records. Syntax:
Trigger trigger_name on Object_Name(trigger_events)
{
Code_block
}
WHERE trigger_events can be comma separated list of events.
Apex Managed Sharing provides developers with the ability to support an application to share a requirements.
This type of sharing available to only users with modify all data permissions. Only this users can add/change apex managed sharing.
Apex Managed Sharing uses a Sharing reason (Apex Sharing Reason)
Q17) What is the Usage of apex program with within visualforce page?
When you want to call apex class in visualforce page we have to declare in the following format.
< Apex : page controller = “class name “ >
Whenever we call a visualforce page in which controller attribute is defined it will first create an object for the apex class which is defined in controller.
When object is created for the apex class first it involves the constructor.
Q18) GROUP BY?
With ApI version 18.0 and later /you can use group by with aggregate functions, such as sum() or max() to summarize the data and enable you to rollup query results rather than having to process the individual records in your code. Syntax :
[ GROUP BY field GROUP BY LIST]
Q19) SOSL Statements In Salesforce Apex?
SOSL statement evaluate to a list of sobjects , where each list contains the search results for a particular sobject type, The result lists are always returned in the same order as they were specified in the query.
If a SOSL query does not return any records for a specified sObject type , the search results include an empty list for that sObject.
For example, you can return a list of accounts, contacts, opportunities and leds that begin with the phase map.
List < list < subject >> search list = [ find 'map*' In ALL FIELDS RETURNING Account (ID, Name), contact, opportunity, lead ];
Note :
The syntax of the classon Apex differs from the syntax of the FIND clause in the SOAP API.
In Apex, the value of the FIND cause is demarcated with single quotes.
Example:
FIND 'map*' IN ALL FIELDS RETURNING account (Id, Name], Contact, Opportunity, Lead.
In the Force.com API, the value of the FIND Clause is demarcated with braces.
For Example:
FIND {map*} IN ALL FIELDS RETURNING account [Id,name], contact ,opportunity,lead.
From search list , you can create arrays for each object returned.
Account [ ] accounts = (( list < accounts > ) search list [0] );
Contact [ ] contacts = [( list ) search list [0]) ;
Opportunity [ ] opportunities = ((list < opportunity> ) search list [2]) ;
Lead [ ] leads = (( list < lead> ) search list [3]);
Q20) Javascript remoting for apex controllers
Use javascript remoting in visualforce to call methods in apex controllers from javascript. Javascript remoting has 3 parts.
The remote method invocation you add to the visualforce page, written in javascript.
The remote method definition in your Apex controller class.
This method definition is written in apex, but there are few differences from normal action methods.
The response handles callback function you add to or include in your vf page, written in javascript.
Q21) Adding javascript remoting to a vf page
To use javascript remoting in a vf page , add the request as a java script invocation with the following from.
[namespace.] controller.method (
[parameters….,]
Call back Function,
[configuration]
);
Name space is the namespace of the controller class
Controllers is the name of your apex controller.
Method is the name of your apex controller method you are calling.
Parameters is the comma-separated list of parameters that your method takes.
Callback function is the name of the javascript function that will handle the response from the controller.
Configuration configures the handling of remote call and response.
Q22) What is the main difference between using data table vs .page block table tags?
PageBlock: For default salesforce standard format.
Data table: To design custom formats
Q23) Which tag is used with both radio buttons and picklists to create the selectable values?
tag
Q24) What is Multitenant Architecture?
An application model in which all users and apps share a single, Common infrastructure and code base.
Q25) What is metadata - driven development model?
An app development model that allows apps to be defined as declarative ‘blueprints”, with no code required. Data Models, objects, forms, workflows, and more are defined by Metadata.
Q26) What are force platform sites?
Public websites and applications that are directly integrated with your salesforce organization without requiring users to log in with a username and password.
Q27) What is AppExchange directory?
A web directory where hundreds of appexchange apps are available to salesforce customers to review, demo, comment upon, and /or install. Developers can submit their apps for listing on the appexchange directory if they want to share them with the community.
Q28) What are some apex classes that are commonly used within controller ?
Standard controller, select option, page reference, message, etc,
Q29) What are the effects of using the transient keyword?
The transient keyword prevents the data from being saved in to view state. This should be used for very temporary variables.
Q30) Configuring javascript remoting requests
Configure a remoting request by proving an object with configuration settings when you declare the remoting request.
javascript remoting supports the following configuration parameters.
Name
Datatype
Description
Buffer
Boolean
Whether to group requests executed close to each other in time into a single request. The default is true.
Escap
Boolean
Whether to escape the apex methods response. The defaults is true.
Timeout
Integer
The timeout for the request in mill Seconds. Default is 30000(30 second)
Q31) How to invoke batch apex job (or) how to execute the batch apex job programmatically
We can use database.executebatch ( ) method to programmatically begin the batch job. Syntax:
Public static ID execute batch ( sObject class name)
Public static ID execute batch (sObject class name, integes scope)
The above two methods are static methods of database class. We can use any one of the method to execute the batch job. NOTE:
The class name what we are passing to the database.execute batch( ) method should be object of the class which has implemented database.batchable interface.
Q32) What is Future Annotation(@Future)?
Use the future annotation to specify that these methods that are executed asynchronously.
Methods with future annotation must be static methods
Methods with future annotation can only return a void type.
Syntax:
global class class_name
{
@future
Static void methodname(parameters)
{
//body of the method
}
Q33) What is Metadata-driven development model?
An app development model that allows apps to be defined as declarative “blueprints,” With no code required. Data model, objects, forms, workflows, and more are defined by metedata.
Q34) What is S-Control?
S-Controls are the predominant salesforce.com widgets which are completely based on JavaScript. These are hosted by salesforce but executed at client side. S-Controls are superseded by VisualForce now.
Q35) Will Visualforce still supports the merge fields usage like S-control?
Yes. Just like S-Controls. Visualforce pages support embedded merge fields.
Q36) What is SOAP?
A protocol that defines a uniform way of passing XML-encoded data. SOAP Stands for Simple Object Access Protocol.
Q37) What is a Time Trigger?
A setting that defines when time-dependent workflow actions should fire.
Q38) Does user can create insert their own custom logo, while creating their own custom applications?
Yes user can upload their custom logo in documents and then they choose that logo for organization.
Q39) List things that can be customized on page layouts?
We can customize different things on page layout like, Fields, Buttons, Custom Links and Related Lists. We can also create sections.
Q41) What are the main things need to consider in the “Master-Detail Relationship”?
Record level access is determined by the parent, Mandatory on child for reference of parent, cascade delete (if you delete the parent, it can cascade delete the child).
Q42) What is the difference between trigger and workflow?
Workflow
Workflow is automated process that fired an action based on Evaluation criteria and rule criteria.
We can access a workflow across the object.
We cannot perform DML operation on workflow
We cannot query from database
Trigger
Trigger is a piece of code that executes before or after a record is inserted or updated.
We can access the trigger across the object and related to that objects
We can use 20 DML operations in one trigger.
We can use 20 SOQL’s from data base in one trigger.
Q44) Difference between SOQL Vs SOSL in salesforce?
SOQL- Salesforce Object Query Language
Using SOQL we can Search only on one object one time.
We can query on all fields of any datatype
We can use SOQL in the Triggers and the classes.
We can perform DML operation on sql query results.
SOSL(Salesforce object Search Language)
Using SOSL we can search on many objects at one time.
We can query only on fields whose data type is text,phone and Email.
We cannot use in Triggers but can in calsses.
We cannot perform DML operation on search results.
Q45) What is difference insert() and database .insert() ?
Using insert method we can insert the records but if any error occurs in any record system will throw an error insertion fail and none of the records are inserted.
If we want to execute partially success of bulk insert operation we will use database .insert.
Q46) What is Static Resources?
Using Static Resources we can upload images, zip files, jar files, javascript and CSS files that can be referred in a visual force page.
The maximum size of Static Resources for an organization is 250mB.
Q47) How to call javascript using Static Resource in Visual Force page?
Add java script file in Static Resource setup -> develop -> Static Resources -> click on ‘New’ -> Name: filename and add file from local desktop and save.
We can use that file as follows in Visual Force page
Q48) What is sharing rule?
If we want to give access to other users we use sharing rules.
Q49) How many ways we can share a record? Role Hierarchy:
If we add a user to a role, the user is above in the role hierarchy will have read access.
Setup --> manage users --> roles --> setup roles --> click on ‘add role’ --> provide name and save.
OWD:
Defines the base line setting for the organization.
Defines the level of access to the user can see the other user’s record
OWD can be Private, Public Read Only, Public Read and Write.
Manual Sharing:
Manual Sharing is sharing a single record to single user or group of users.
We can see this button detail page of the record and this is visible only when OWD setting is private.
Criteria Based Sharing rules:
If we want to share records based on condition like share records to a group of users
Whose criteria are country is India.
Setup -> security controls -> sharing settings -> select the object and provide name and Conditions and save
Apex sharing:
Share object is available for every object(For Account object share object is AccountShare ). If we want to share the records using apex we have to create a record to the share object.
Q50) Unit testing code which has logic around the CreatedDate
You can create sObjects in memory with arbitrary CreatedDate values by using JSON.deserialize. This doesn’t enforce the normal read-only field attributes that prevent you from setting a createdDate value. However, you can’t commit arbitrary CreatedDate values to the database (or else it would be a serious security issue).
An example of doing so :
String caseJSON = ‘{“attributes”:{“type”:”Case”,”url”:”/services/data/v25.0/sobjects/Case/500E0000002nH2fIAE”},
“Id”:”500E0000002nH2fIAE”,
“CreatedDate”:”2012-10-04T17:54:26.000+0000″}’;
Case c = (Case) JSON.deserialize(caseJSON, Case.class );
System.debug(c.createdDate);
Note that I built the caseJSON string by creating a test case and serializing it, which is the easiest way to get JSON similar to what you want, then you can just tweak the values.
Q51) Ignoring Validation rules when deploying code
I have seen a solution that uses a Custom Setting of ValidationRuleEnabled.
When you want to deploy any code then the administrator changes the Custom Setting to FALSE, deploy the new code; don’t forget to re-enable the Custom Setting!
Again this is not ideal as the ‘legacy’ code should be updated to accommodate the new validation rules; ideally at the time of creating the new validation rules (but who checks code coverage after making a small change like a validation rule)
Q52) Can I find out if the current user has access to a record without querying?
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=:UserInfo.getUserId()
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.
Q54) What is a concise function that formats a (String) decimal into a currency format in Apex?
@RickMeasham’s method is a good one, but I ran into a couple rounding issues with negative values and fractional values. Here’s my edited version of the method that passes the tests I needed it to (not rendering -0.001 as “-0.00”, not rendering -1.10 as “-1.09”).
public static String formatCurrency(Decimal i)
{
if (i == null || Math.abs(i) < 0.005) return ‘$0.00’;
String s = (i.setScale(2) + (i >= 0 ? 0.001 : -0.001)).format();
return s.substring(0, s.length() – 1);
}
(EDIT: changed “<= 0.005” to “< 0.005” per @RickMeasham’s advice below.)
(EDIT 2: actually realized, when I finished tests, that this updated method still had a few shortcomings related to rounding. I updated to delegate to Math.roundToLong per code below [which uses round half even, not half up as I stated in my comments erroneously]. It now passes all my unit tests, which you can see here: https://codepad.org/ycttSXjq)
private String formatCurrency(Decimal i)
?{
if (i == null) return ‘0.00’;
i = Decimal.valueOf(Math.roundToLong(i * 100)) / 100;
String s = (i.setScale(2) + (i >= 0 ? 0.001 : -0.001)).format();
return s.substring(0, s.length() – 1);
}
Q55) How do you write a unit test for a trigger whose only function is to make a callout?
Both future methods and callouts can be unit tested.
To test future methods simply make your call to any future method between Test.startTest();and Test.stopTest(); statements and the future method will return when Test.stopTest(); is called. See the documentation for the Test class here: System. Test
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 Test.isRunningTest() and instead of getting your callout response from an HttpResponse.send() request, you return a pre-built test string instead. There’s one example of this method here: https://www.iterativelogic.com/unit-test-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 Test.isRunningTest() and their example works fairly well as well. That example can be found here:https://sfdc.arrowpointe.com/2009/05/01/testing-http-callouts/
Q56) Can report data be accessed programmatically?
Update for Winter ’14
API:
I think the biggest announcement that developers have been waiting for API wise is the availability of our Analytics API. We introduced a limited pilot in summer 13 and now the Analytics REST API is generally available. The Analytics API lets you integrate Salesforce report data into your apps programmatically and has several resources that let you query metadata, and record details.
Source – Winter 14 Developer Preview
Q57) How do you unit test a trigger when you don’t know the required fields?
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: https://blogs.developerforce.com/developer-relations/2012/05/dynamic-apex-class-instantiation-in-summer-12.html
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.
Q58) Deleting a class without IDE
This can be done with the Force.com Migration
Tool:https://wiki.developerforce.com/page/Force.com_Migration_Tool
See the full documentation here: https://wiki.developerforce.com/page/Force.com_Migration_Tool
The tool can create or delete any meta-data that can be created through the Force.com IDE or Change Sets. It comes with a sample config file that contains example deployments for deploying objects and Apex code and deleting them as well. The documentation has a very detailed step-by-step guide here: https://www.salesforce.com/us/developer/docs/daas/index_Left.htm#StartTopic=Content/forcemigrationtool.htm
Q59) Is there a defacto 3rd party utilities library for Apex such as Apache Commons is for Java?
Apex-lang is about as close to a Java-style library as you can get. Contains several string, database, and collection utilities that mimmick Java functionality. Be aware though, some stuff including Comparing and Sorting collections is out of date with the advent of the Comparable interface in Apex.In addition to apex-lang, and like you suggest, I typically create or reuse static helper methods throughout my projects. Static helper methods are very convenient for reusing code in Chatter functionality, DML handling, Exception handling, Unit testing, etc.
Q60) Using transient keyword to store password in hierarchy custom setting
Because your myPref property is transient the initialisation you perform in the constructor won’t round trip when the page posts back.
When I’ve used transient and a protected custom setting I use separate properties that are transient and then only work with the custom setting in the post back method.
Controller
Skip code block
public with sharing class TestCustomSettings
{
// transient to ensure they are not transmitted as part of the view state
public transient String password1 {get; set;}
public transient String password2 {get; set;}
public PageReference save() {
// I’ve changed this to getInstance() rather than getValues()
TestR__c myPref = TestR__c.getInstance(UserInfo.getOrganizationId());
if(myPref == null) {
myPref = new TestR__c();
myPref.SetupOwnerId = Userinfo.getOrganizationId();
}
myPref.Password1__c = password1;
myPref.Password2__c = password2;
// Note that by using upsert you don’t need to check if the Id has been set.
upsert myPref;
}
}
Visualforce page
You can use inputSecret rather than inputField in the Visualforce page so that the browser will mask the input.
Q61) Is there a way to setup continous integration for apex tests?
There are a couple of decent Dreamforce presentations here: Team Development: Possible, Probable, and Painless and Continuous Integration in the Cloud.
We ran into some issues with this in practice and there was no way to get true automation (i.e., set it and forget it). We were also set it up with Selenium.
Here were the issues that I remember.
Some features aren’t supported in the metadata API and cannot be moved via the ant migration. If you have any unit tests that work with those features, you have to manually work on your CI org.
Deletions are harder to maintain. You have to manually update and apply a destructiveChanges.xml file or replicate the deletion in the CI org.
We ran into a situation where some metadata XML files had ‘invalid’ data in them. The suggested solution was to build a post checkout script that manipulates the offending XMLs into valid XMLs. Not ideal.
On projects, we wanted to track just our changes and push out just our changes in source control. In theory, this would allow much easier rebaselining. This would have required more manual maintenance of XML files (e.g., 2 new fields added on Account and only want to push those 2 fields not all (*) fields).
My conclusion is that it is worth doing if you can get it set up, but if you are working on shorter-term projects and don’t have a decent amount of time budgeted in for it, it probably isn’t worth setting up. Although it isn’t CI, check out https://developer.force.com/cookbook/recipe/automated-unit-test-execution. You could set it up to run every hour or something like that.
Q62) What are the implications of implementing Database. Stateful?
Daniel Ballinger: No, batches do not ever run simultaneously. You are correct, however, that serialization is the culprit here.
grigriforce: what’s your batch size? If you’re doing a million records, and your batch size is 1, then you will serialize/deserialize your state 1M times. Even with a small serialized object, that’s gonna hurt.
Q63) What are the recommended ways to refactor in Apex?
I use the second method. After refactoring, I select the ‘src’ folder, use File Search/Replace and all the changes are made and saved to the server in one go.
Q64) What is a good set of naming conventions to use when developing on the Force.com platform?
Follow the CamelCase Java conventions, except for VF pages and components start with a lower case letter. Triggers:
Trigger – The trigger itself. One per object.
TriggerHandler – Class that handles all functionality of the trigger
TriggerTest
Controllers:
Controller
ControllerExt
ControllerTest
ControllerExtTest
Classes:
Test (These might be Util classes or Service classes or something else).
Visualforce pages and components:
[optionalDescription] (without the suffix Controller). There might be multiple views so could also have an extra description suffix.
Object Names and custom Fields
Upper_Case_With_Underscores
Variables/properties/methods in Apex
camelCaseLikeJava – more easily differentiated from fields
Test methods in test classes
test-For example, testSaveOpportunityRequiredFieldsMissing, testSaveOpportunityRequiredFieldsPresent, etc.
Working on something that would be used as an app or in some cases just a project? If yes, then do the following:
Prefix all custom objects, apex classes, Visualforce pages and components with an abbreviation so that they are easier to identify (e.g., easier for changesets). For example the WidgetFactory app would have the prefix wf on those. Additionally, when adding custom fields to a standard object they would also be prefixed to identify them as part of the app/package.
The main reason for the Object and Fields Names using Upper_Case_With_Underscores is that when you type in the name field or object with spaces it automatically adds the underscores. Although Apex is case insensitive, always refer to the Objects and Custom Fields in the code as Upper_Case_With_Underscores as well for consistency all around and consistency with what is generated by the SOQL schema browser and other tools. Object and Field Labels (which are generally ignored by code but visible to users) should keep spaces, not underscores.
Q65) Why use Batch Apex?
A Batch class allows you to define a single job that can be broken up into manageable chunks that will be processed separately.
One example is if you need to make a field update to every Account in your organization. If you have 10,001 Account records in your org, this is impossible without some way of breaking it up. So in the start() method, you define the query you’re going to use in this batch context: ‘select Id from Account’. Then the execute() method runs, but only receives a relatively short list of records (default 200). Within the execute(), everything runs in its own transactional context, which means almost all of the governor limits only apply to that block. Thus each time execute() is run, you are allowed 150 queries and 50,000 DML rows and so on. When that execute() is complete, a new one is instantiated with the next group of 200 Accounts, with a brand new set of governor limits. Finally the finish() method wraps up any loose ends as necessary, like sending a status email.
So your batch that runs against 10,000 Accounts will actually be run in 50 separate execute() transactions, each of which only has to deal with 200 Accounts. Governor limits still apply, but only to each transaction, along with a separate set of limits for the batch as a whole.
Disadvantages of batch processing:
It runs asynchronously, which can make it hard to troubleshoot without some coded debugging, logging, and persistent stateful reporting. It also means that it’s queued to run, which may cause delays in starting.
There’s a limit of 5 batches in play at any time, which makes it tricky to start batches from triggers unless you are checking limits.
If you need access within execute() to some large part of the full dataset being iterated, this is not available. Each execution only has access to whatever is passed to it, although you can persist class variables by implementing Database.stateful.
There is still a (fairly large) limit on total Heap size for the entire batch run, which means that some very complex logic may run over, and need to be broken into separate batches.
Q66) Documenting Salesforce.com Apex class files
I have used apexDoc for a while and we are starting to roll it out more fully for our use at my organization. It is open source software and so you could always contribute some updates for it :-) What features are you wanting to add to it that it doesn’t have (just to give a flavor)?
In answer to your questions
1. I don’t think anybody has successfully managed to do this. There is an idea of the ideas exchange for it to be done but it seems to gain very little support.
2. Theoretically, it should be pretty easy as apex is a Java DSL. Have you tried running Doxygen and if so what errors does it throw up?
3. I use ApexDoc to generate some basic output and then have a little script tied in to copy across custom css and things. It isn’t perfect but it does for the small amount we need at the moment.
I believe the IDE is being open sourced at some time in which case I would imagine the antlr grammar file would become available which may help you out.
I know it is not really an answer for what you wanted to hear per se, but sadly it’s all we have atm (and I would love a nicer documentation generator!!)
Paul
Q67) Workarounds for Missing Apex Time.format() Instance Method
You could just split the DateTime format() result on the first space – does that give you what you’re looking for?
public String myDateFormat(DateTime dt)
{
String[] parts = dt.format().split(‘ ‘);
return (parts.size() == 3) ? (parts[1] + ‘ ‘ + parts[2]) : parts[1];
}
produces
6:38 PM
for me in English (United States), and
18:42
in French(France).
UPDATE
As tomlogic points out, the above method is not very robust – some locales may include spaces in the date or time portion of the format, and the ordering is not consistent. This second attempt assumes that the date and time are separated by zero or more spaces, but handles spaces within the two portions, and either ordering of date and time. The only assumption made is that the formatted Date is contained within the formatted Time:
public String myDateFormat(DateTime dt)
{
return dt.format().replace(dt.date().format(), ”).trim();
}
Seems to work fine for Hebrew, Vietnamese & Korean, as well as English and French.
Q68) Is there an average method for apex math
Unfortunately, the standard math methods only include simpler operations (i.e. those that work on a single, or two values), so it looks as though you’ll have to roll your own method.
Of course, the number of script statements executed will be proportional to the length of the list, so of the lists are ever of a fixed size it could be worth using a macro to generate the addition part for you:
Int sum = i[0] + i[1] + … i[n];
Doing so would only count for one statement, but you’ll only need this if governor limits are of concern which is often not a worry.
If govenor limits aren’t an issue you could create a function along these lines:
Skip code block
Integer[] myInts = new Integer[]{1, 2, 3, 4, 5, 6, 7};
Integer total = 0;
Double dAvg;
for (Integer i : myInts) {
total += i;
}
dAvg = Double.valueOf(total) / myInts.size();
return dAvg;
Q69) Grammar for creating an Apex parser
Keep an eye on Apex tooling api, which is used in Developer console. This is supposed to be released to public access soon.
Q70) Does ‘default value’ do anything if the object is created through Apex?
New feature coming in the next release:
Foo__c f = Foo__c.sobjecttype.newSObject(
recordTypeId, // can be null
true); // loadDefaultValues
Q71) Detect the current LoggingLevel in Apex
Unfortunately, I don’t think there is a way to check the current logging level in APEX.
Q72) Call Apex class method on the fly (dynamically)
While you can instantiate a class based on its name using the Type system class, you can’t dynamically locate a method and execute it. The best that you can do is to dynamically create an instance of a class that implements an interface and executes one of the methods on the interface.
There’s more information on the Type class and an example in the :
Apex Developer’s Guide
Q73) SOQL – query a query
It sounds like you’re talking about using nested SOQL queries. Here’s an example of querying a parent and two child objects in one query, using the relationship name for each related list of objects:
list accswithchildren = [select Id, Name, CreatedDate,
(select Id, CreatedDate from Tasks order by CreatedDate desc limit 1),
(select Id, Service_Date__c from Custom_Object__r order by Service_Date__c desc limit 1)
from Account where Id in :setofids];
You can then loop through those Accounts in Apex, and for each one, there is a list (size 0 or 1) of Tasks and Custom_Object__c:
for (Account a : accswithchildren)
{
list theseTasks = a.Tasks;
list otherobjects = a.Custom_Object__r;
//do something with these records
}
Q74) What’s the best way to check if person accounts are enabled via Apex Code?
I’ve found two methods to accomplish this. Method 1
Try to access the isPersonAccount property on an Account and catch any exception that occurs if that property is missing. If an exception is generated then person accounts are disabled. Otherwise they’re enabled. To avoid making person accounts required for the package you assign the Accountobject to an sObject and use sObject.get( ‘isPersonAccount’ ) rather than accessing that property directly on the Account object.
This method takes ~3.5ms and negligible heap space in my testing.
Skip code block
// Test to see if person accounts are enabled.
public Boolean personAccountsEnabled()
{
try
{
// Try to use the isPersonAccount field.
sObject testObject = new Account();
testObject.get( ‘isPersonAccount’ );
// If we got here without an exception, return true.
return true;
}
catch( Exception ex )
{
// An exception was generated trying to access the isPersonAccount field
// so person accounts aren’t enabled; return false.
return false;
}
}
Method 2
Use the account meta-data to check to see if the isPersonAccount field exists. I think this is a more elegant method but it executes a describe call which counts towards your governor limits. It’s also slightly slower and uses a lot more heap space.
This method takes ~7ms and ~100KB of heap space in my testing.
// Check to see if person accounts are enabled.
public Boolean personAccountsEnabled()
{
// Describe the Account object to get a map of all fields
// then check to see if the map contains the field ‘isPersonAccount’
return Schema.sObjectType.Account.fields.getMap().containsKey( ‘isPersonAccount’ );
}
Q75) Can’t Deploy Due to Errors in 3rd Party Packages
It was previously possible to install managed packages and Ignore APEX Test Errors this isn’t the case anymore.
You are probably going to have to uninstall them if you want to deploy from Sandbox to production and reinstall them.
If it’s Milestones PM (the package) is you can probably get an unmanaged version to work with and fix the bugs.
UPDATE
Looks like you are using the unmanaged package. So I think if you don’t want to uninstall before going to production your going to have to fix those errors manually by fixing the code.
Unfortunately, SFDC test methods don’t live in a complete vacuum where you can run tests against your org without bumping other code, even when you go to deploy.
Q76) How Can I Tell the Day of the Week of a Date?
Formulas
There isn’t a built-in function to do this for you, but you can figure it out by counting the days since a date you know. Here’s the concept: I know that June 29, 1985 was a Saturday. If I’m trying to figure out the day of the week of July 9 of that year, I subtract the dates to determine the number of days (10), and then use modular division to figure to remove all the multiples of 7. The remainder is the number of days after Saturday (1 = Sunday, 2 = Monday, etc.) and you can use that number in your logic:
Apex Code
You could do the same thing with time deltas, but you can also use the poorly
documentedDateTime.format() function:
// Cast the Date variable into a DateTime
DateTime myDateTime = (DateTime) myDate;
String dayOfWeek = myDateTime.format(‘E’);
// dayOfWeek is Sun, Mon, Tue, etc.
Q77) What is App in Salesforce?
An app is a group of tabs that work as a unit to provide functionality. Users can switch between apps using the Force.com app drop-down menu at the top-right corner of every page.
You can customize existing apps to match the way you work or build new apps by grouping standard and custom tabs.
Navigation to create an app in Salesforce: Setup ->Build ->Create->App-> Click on new and create your application according to your requirements.
Q78) What is the object in Salesforce.com?
Objects are database tables that allow you to store data specific to your organization in salesforce. You can use custom objects to extend salesforce.com functionality or to build new application functionality.
When you create a custom object, we can create a custom tab, customized related lists, reports, and dashboards for users to interact with the object data. You can also access custom object data through the Force.com API.
Navigation to create an object in sales force: Setup-->Build-->Create-->Object--> Click on new object and create object according to your requirement.
Q84) List examples of custom field types?
Text, Pick list, Pick list (multi select), Date, Email, Date/Time, Date, Currency, Checkbox, Number, Percent, Phone, URL, Text Area, Geolocation, lookup relationship, master detail relationship etc…..
Q85) What is TAB in Salesforce?
Tab is a user interface component to user creates to display custom object data.
There are three type of tabs.
Custom Tabs
Visual force Tabs
Web Tabs
Q86) What are the actions in workflow?
Email Alert
Task
Field Update
Outbound Message
Go through the below link for the more information about workflow actions HTTP://WWW.SALESFORCETUTORIAL.COM/SALESFORCE-WORKFLOW-AUTOMATION-WORKFLOW-MANAGEMENT/
Q87) How many ways we can made field is required?
While creation of field
Validation rules
Page Layout level
Q88) What is difference between Role and Profile?
Role is Record-level access and it is not mandatory for all users.
Profile is object level and field level access and it is mandatory for all users.
Q89) What is the maximum size of the PDF generated on visualforce attribute renderAs?
15MB
Q90) How many controllers can be used in a visual force page?
Salesforce come under SAAS so, we can use one controller and as many extension controllers.
Q91) What is the difference between Action support and Action function?
Action function: Invoke the controller method from java script using AJAX and we can use action function from different places on visual force page.
Action support: Invoke the controller method using AJAX when even occurs on page like onMouseOver, onClick, ect… and we can use action support for particular single apex component.
Q92) How many ways we can call the Apex class?
Visual forcepage
Web Service
Triggers
Email services
Q94) What is permission set?
Permission sets extend user’s functional access without changing user’s profile.
Ex: A user has only read access through profile on custom object, administrator want to give access Edit and create operations to him without changing the profile. Administrator creates the permission set having edit and creates operation on custom object and assign to that user.
Q95) What is manual sharing?
Manual sharing is to share a record to a particular user manually.
Go to detail page of record and click on manual sharing button and assign that record to other user with Read or Read/Write access.
Manual Sharing button enables only when OWD is private to that object.
Q96) How we can change the Grant access using role hierarchy for standard objects?
Not possible.
Q97) Explain the uses of “Transfer Record” in profile?
If user have only Read access on particular record but he wants to change the owner name of that record, then in profile level Transfer Record enables he can able to change the owner.
Q98) What is Field dependency?
According to the field selection on one field filter the pick list values on other field.
Q99) Is check box performs like controlling field?
Yes possible. Controlling field should be Check box or pick list.
Q100) How many field dependencies we can use in Visual Force page?
Maximum we can use 10 field dependencies in VF page.
Q101) What is Roll-up summary?
Roll-up displays the count of child records and calculate the sum, min and max of fields of the child records.
Q104) What are Record Types?
Record Types are restrict the pick list values and assign to the different page layouts for different Record Types.
Q105) What is Audit Trail?
Audit Trail provides the information or track all the recent setup changes that an administrator done to the organization.
This can store the last 6 months data.
Q107) What is Dashboard?
Dashboard is a pictorial representation of report. We can add up to 20 reports in single dashboard.
Salesforce Vs ServiceNow
SalesForce
ServiceNow
Platforms
Desktop, Mobile, Cloud
Cloud
Type of Software
Stand alone, Cloud, Saas
Stand alone, Cloud, Saas
Key Features
Markeitng Sales Management, Customer Management, Customer Service
Information Technology, Customer Management, Customer Service
Price
Preferred by all types of customers as it is cost effective
Approximately four time more than Salesforce
Typical Customers
Small, Mid and Enterprise
Mid and Enterprise
Security
Moderate
Best when compared to Salesforce
----- Write a JOB ------
public with sharing class TaskUtils {
public static void remindOwners(List oppList) {
List taskList = new List();
For(Opportunity opp : oppList) {
Task newTask = new Task( WhatId = opp.Id,
OwnerId = opp.OwnerId,
ActivityDate = Date.today(),
Subject = 'Update Opportunity',
Description = 'Kindly close the ticket by the end of the day');
taskList.add(newTask);
}
insert taskList;
}
}
----- Call it from a Schedulable Class -------
global class RemindOpptyOwners implements Schedulable {
global void execute(SchedulableContext ctx) {
List opptys = [SELECT Id, Name, OwnerId, CloseDate
FROM Opportunity
WHERE IsClosed = False AND
CloseDate < TODAY];
// Create a task for each opportunity in the list
TaskUtils.remindOwners(opptys);
}
}
From Setup, enter Apex Classes in the Quick Find box,
    select Apex Classes, and then click Schedule Apex.
Specify the name of a class that you want to schedule.
Specify how often the Apex class is to run.
For Weekly—specify one or more days of the week the job is to run (such as Monday and Wednesday).
For Monthly—specify either the date the job is to run or the day (such as the second Saturday of every month.)
Specify the start and end dates for the Apex scheduled class. If you specify a single day, the job only runs once.
Specify a preferred start time. The exact time the job starts depends on service availability.
Click Save
Things to Remember
We can have upto 100 scheduled Apex jobs at one time
When scheduleing a class from a trigger. We must make sure the tigger does not add more scheduled jobs than the limit.
Synchronous Web service callouts are not supported from scheduled Apex. To be able to make callouts, make an asynchronous callout by placing the callout in a method annotated with @future(callout=true) and call this method from scheduled Apex. However, if your scheduled Apex executes a batch job, callouts are supported from the batch class.
// Trigger Exceptions:
// addError UseCase - Prevent the deletion of accounts if they have related opportunities.
trigger AccountDeletion on Account (before delete) {
for (Account a : [SELECT Id FROM Account
WHERE Id IN (SELECT AccountId FROM Opportunity) AND
Id IN :Trigger.old]) {
Trigger.oldMap.get(a.Id).addError(
'Cannot delete account with related opportunities.');
}
// After Insert UseCase - when you need to associate any record to a record being created
// Automatically create an Opp when an Account is created
trigger AutoOpp on Account(after insert) {
List newOpps = new List();
for (Account acc : Trigger.new) {
Opportunity opp = new Opportunity();
opp.Name = acc.Name + ' Opportunity';
opp.StageName = 'Prospecting';
opp.CloseDate = Date.today() + 90;
opp.AccountId = acc.Id; // Use the trigger record's ID
newOpps.add(opp);
}
insert newOpps;
}
Order of execution
Old record loaded from database (or initialized for new inserts)
New record values overwrite old values
System Validation Rules
All Apex “before” triggers
Custom Validation Rules
Record saved to database (but not committed)
Record reloaded from database
All Apex “after” triggers
Assignment rules
Auto-response rules
Workflow rules
Escalation rules
Parent Rollup Summary Formula value updated (if present)
Database commit
Post-commit logic (sending email)
Things to consider -
Trigger.new and Trigger.old cannot be used in Apex DML operations
You can use an object to change its own field values using trigger.new, but only in before triggers. In all after triggers, trigger.new is not saved, so a runtime exception is thrown
Old is always read-only
You cannot delete trigger.new
1. Can two users have the same profile? Can two profiles be assigned to the same user?
Profiles determine the level of access a user can have in a Salesforce org.
As far as the first part of the question is concerned, Yes. One profile can be assigned to any number of users. Take the example of a Sales or Service team in a company. The entire team will be assigned the same profile. The admin can create one profile: Sales Profile, which will have access to the Leads, Opportunities, Campaigns, Contacts and other objects deemed necessary by the company.
In this way, many users can be assigned the same profile. In case the team lead or manager need access to additional records/ objects then it can be done by assigning permission sets only for those users.
Answering the second part of the question, each user can only be assigned 1 profile.
2. What are Governor Limits in Salesforce?
In Salesforce, it is the Governor Limits which controls how much data or how many records you can store in the shared databases. Why? Because Salesforce is based on the concept of multi-tenant architecture. In simpler words, Salesforce uses a single database to store the data of multiple clients/ customers. The below image will help you relate to this concept.
To make sure no single client monopolizes the shared resources, Salesforce introduced the concept of Governor Limits which is strictly enforced by the Apex run-time engine.
Governor Limits are a Salesforce developer’s biggest challenge. That is because if the Apex code ever exceeds the limit, the expected governor issues a run-time exception that cannot be handled. Hence as a Salesforce developer, you have to be very careful while developing your application.
Different Governor Limits in Salesforce are:
Per-Transaction Apex Limits
Force.com Platform Apex Limits
Static Apex Limits
Size-Specific Apex Limits
Miscellaneous Apex Limits
Email Limits
Push Notification Limits
3. What is a sandbox org? What are the different types of sandboxes in Salesforce?
A sandbox is a copy of the production environment/ org, used for testing and development purposes. It’s useful because it allows development on Apex programming without disturbing the production environment.
When can you use it? You can use it when you want to test a newly developed Force.com application or Visualforce page. You can develop and test it in the Sandbox org instead of doing it directly in production.
This way, you can develop the application without any hassle and then migrate the metadata and data (if applicable) to the production environment. Doing this in a non-production environment allows developers to freely test and experiment applications end to end.
Types of Sandboxes are:
Developer
Developer Pro
Partial Copy
Full
4. Can you edit an apex trigger/ apex class in production environment? Can you edit a Visualforce page in production environment?
No, it is not possible to edit apex classes and triggers directly in production environment.
It needs to be done first in Developer edition or testing org or in Sandbox org. Then, to deploy it in production, a user with Author Apex permission must deploy the triggers and classes using deployment tools.
However, Visualforce pages can be created and edited in both sandbox and in production.
Only if the page has to do something unique (different values), it would have to be developed via Sandbox.
5. What are the different data types that a standard field record name can have?
A standard field record name can have data type of either auto number or text field with a limit of 80 chars.
For generating auto numbers, the format needs to be specified while defining the field and after that for every record that is added, the number will get auto generated. For example:- Sr No-{1} Sr No-{2} Sr No-{3}
6. Why are Visualforce pages served from a different domain?
Visualforce pages are served from a different domain to improve security standards and block cross site scripting. Take a look at the highlighted portion in the below Visualforce page:-
B. Declarative Features – Salesforce Interview Questions
7. What is WhoId and WhatId in activities?
WhoID refers to people. Typically: contacts or leads. Example: LeadID, ContactID
WhatID refers to objects. Example: AccountID, OpportunityID
8. What is the use of writing sharing rules? Can you use sharing rules to restrict data access?
Sharing rules are written to give edit access (public read and write) or public read onlyaccess to certain individuals in Salesforce org. A classic example is when:- only your managers or superiors need to be given extra credentials to your records in objects as compared to your peers.
By default, all users in your organization will have organization-wide-default sharing settings of either Public Read Only or Private. To give access to more records, which users do not own, we write sharing rules. Example: Sharing rules are used to extend sharing access to users in public groups or roles. Hence, sharing rules are not as strict as organization-wide default settings. They allow greater access for those users.
As far as the second part of the question is concerned, the answer is no. We cannot use sharing rules to restrict data access. It is only used for allowing greater access to records.
9. What are the different types of email templates that can be created in Salesforce?
The different types of Email templates are listed in the below table:-
Text
All users can create or change this template
HTML with letterhead
Only Administrators and users having “Edit HTML Templates” permissions can create this template based on a letterhead.
Custom HTML
Administrators and users having “Edit HTML Templates” permissions can create this template without the need of a letterhead
Visualforce
Only administrators and developers can create this template. Advanced functionalities like merging data from multiple records is available only in this template
C. Audit & Reporting Features – Salesforce Interview Questions
10. What is a bucket field in reports?
A bucket field lets you group related records together by ranges and segments, without the use of complex formulas and custom fields. Bucketing can thus be used to group, filter, or arrange report data. When you create a bucket field, you need to define multiple categories (buckets) that are used to group report values.
The advantage is that earlier, we had to create custom fields to group or segment certain data.
11. What are dynamic dashboards? Can dynamic dashboards be scheduled?
Before we understand dynamic dashboards, let us first understand static dashboards. Static dashboards are the basic dashboard types that will be visible to any user who has made a report out of his data. An example of this is what a Sales manager/ Marketing manager would be able to see on his Salesforce org. In other words, a normal dashboard shows data only from a single user’s perspective. Now comes the concept of dynamic dashboards.
Dynamic dashboards are used to display information which is tailored to a specific user. Let us consider the same example as above. In case the Sales manager wants to view the report generated specific to only one of his team members, then he can use dynamic dashboards.
You can use dynamic dashboards when you want to show user-specific data of a particular user, such as their personal quotas and sales, or number of case closures, or leads converted etc. You can also use a normal/ static dashboard when you want to show regional or organization-wide data to a set of users, such as a particular region’s sales number, or a particular support team’s performance on case closures.
As far as the second part of the question is concerned, no we cannot schedule a dynamic dashboard. That is because whenever we open the dashboard, it will show the data generated in real-time.
12. What are the different types of reports available in Salesforce? Can we mass delete reports in Salesforce?
Salesforce Report Types
1. Tabular reports
Simple Excel type tables which provide a list of items with the grand total
2. Summary reports
Similar to Tabular reports, but also have functionality of grouping rows, viewing subtotals & creating charts
3. Matrix reports
Two-dimensional reports which allow you to group records both by row and column
4. Joined reports
Multiple blocks showing data from different reports based on same or different report types
Another important point to note here is that, only Summary reports and Matrix reports can be fed as data source for dashboards. Tabular and Joined reports cannot be used as data source for dashboards.
Can we mass delete reports in Salesforce? Of Course we can mass delete reports in Salesforce. The option to mass delete reports can be found under Data Management in Setup.
D. Data Modelling & Data Management – Salesforce Interview Questions
16. Explain the term “Data Skew” in Salesforce.
“Data skew” is a condition which you will encounter when working for a big client where there are over 10,000 records. When one single user owns that many records we call that condition ‘ownership data skew’.
When such users perform updates, performance issues will be encountered because of “data skew”. This happens when a single user/ members of a single role own most of the records for a particular object.
17. Explain skinny table. What are the considerations for Skinny Table?
In Salesforce, skinny tables are used to access frequently used fields and to avoid joins. This largely improves performance. Skinny tables are highly effective, so much so that even when the source tables are modified, skinny tables will be in sync with source tables.
Considerations for skinny tables:
Skinny tables can contain a maximum of 100 columns.
Skinny tables cannot contain fields from other objects.
For full sandboxes: Skinny tables are copied to your Full sandbox organizations, as of the Summer ’15 release.
18. Which fields are automatically Indexed in Salesforce?
Only the following fields are automatically indexed in Salesforce:
Primary keys (Id, Name and Owner fields).
Foreign keys (lookup or master-detail relationship fields).
Audit dates (such as SystemModStamp).
Custom fields marked as an External ID or a unique field.
19. How to handle comma within a field while uploading using Data Loader?
In a Data Loader .CSV, if there is a comma in field content, you will have to enclose the contents within double quotation marks: ” “.
E. Logic & Process Automation – Salesforce Interview Questions
20. For which criteria in workflow “time dependent workflow action” cannot be created?
Time dependent workflow action cannot be create for: “created, and every time it’s edited”.
21. What are the types of custom settings in Salesforce? What is the advantage of using custom settings?
There are two types of custom settings in Salesforce: List Custom Settings and Hierarchy Custom Settings.
List Custom Settings are a type of custom settings that provides a reusable set of static data that can be accessed across your organization irrespective of user/ profile. Hierarchy Custom Settings are another type of custom settings that uses built-in hierarchical logic for “personalizing” settings for specific profiles or users.
The advantage of using custom settings is that it allows developers to create a custom set of access rules for various users and profiles.
22. How many active assignment rules can you have in a lead/ case?
Only one rule can be active at a time.
23. What are custom labels in Salesforce? What is the character limit of custom label?
Custom labels are custom text values that can be accessed from Apex classes or Visualforce pages. The values here can be translated into any language supported by Salesforce. Their benefit is that they enable developers to create multilingual applications which automatically presents information in a user’s native language.
You can create up to 5,000 custom labels for your organization, and they can be up to 1,000 characters in length.
24. What is the difference between a Role and Profile in Salesforce?
As mentioned in one of the previous Salesforce interview questions, a profile will ultimately control access to which records a user has in a Salesforce org. No user can work on the Salesforce org without being assigned a profile. The Profile is therefore mandatory for every user.
Role however is not mandatory for every user. The primary function of the Role/ Role hierarchy is that it allows higher level users in hierarchy get access to records owned by lower level users in the hierarchy. An example of that is Sales Managers getting access to records owned by Sales Reps while their peers do not get access to it.
25. What are the examples of non-deterministic Force.com formula fields?
Before I mention some of the examples, let me give you an introduction to deterministic and non-deterministic formula fields. Formula fields whose value will be static are referred to as deterministic fields. Whereas, formula fields whose value will be changed dynamically or whose values will have to be calculated on the fly, they are referred to as non-deterministic formula fields. A classic example of that is a formula returning the current date and time.
Some examples of non-deterministic fields in Force.com are:
Lookup fields
Formula fields whose reference spans over other entities
Fields having dynamic date functions like:- TODAY() or NOW()
F. Software Testing – Salesforce Interview Questions
26. Why do we need to write test classes? How to identify if a class is a test class?
Software developers from around the world will unanimously agree that writing code in test classes makes debugging more efficient. Why? That is because test classes help in creating robust and error-free code be it Apex or any other programming language. Since Unit tests are powerful in their own right, Salesforce requires you to write test classes in Apex code.
Why are they so powerful? Because test classes and test methods verify whether a particular piece of code is working properly or not. If that piece of code fails, then developers/ testers can accurately locate the test class having the faulty bug.
Test classes can be determined easily because every test class will be annotated with @isTest keyword. In fact, if we do not annotate a test class with @isTest, then it cannot be defined as a test class. Similarly, any method within a class which has the keyword testMethod, is a test method.
27. What is minimum test coverage required for trigger to deploy?
In Salesforce, if you want to deploy your code to production, then you must make sure that at least 75% of your Apex code is covered by unit tests. And all these tests must complete successfully.
G. Debug & Deployment Tools – Salesforce Interview Questions
28. What are the different ways of deployment in Salesforce?
You can deploy code in Salesforce using:
Change Sets
Eclipse with Force.com IDE
Force.com Migration Tool – ANT/Java based
Salesforce Package
H. Integration – Salesforce Interview Questions
29. What is an external ID in Salesforce? Which all field data types can be used as external IDs?
An external ID is a custom field which can be used as a unique identifier in a record. External IDs are mainly used while importing records/ data. When importing records, one among the many fields in those records need to be marked as an external ID (unique identifier).
An important point to note is that only custom fields can be used as External IDs. The fields that can be marked as external IDs are: Text, Number, E-Mail and Auto-Number.
30. How many callouts to external service can be made in a single Apex transaction?
Governor limits will restrict a single Apex transaction to make a maximum of 100 callouts to an HTTP request or an API call.
31. How can you expose an Apex class as a REST WebService in Salesforce?
You can expose your Apex class and methods so that external applications can access your code and your application through the REST architecture. This is done by defining your Apex class with the @RestResource annotation to expose it as a REST resource. You can then use global classes and a WebService callback method.
Invoking a custom Apex REST Web service method always uses system context. Consequently, the current user’s credentials are not used, and any user who has access to these methods can use their full power, regardless of permissions, field-level security, or sharing rules.
Developers who expose methods using the Apex REST annotations should therefore take care that they are not inadvertently exposing any sensitive data. Look at the below piece of code for instance:-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
global class AccountPlan {
webservice String area;
webservice String region;
//Define an object in apex that is exposed in apex web service
global class Plan {
webservice String name;
webservice Integer planNumber;
webservice Date planningPeriod;
webservice Id planId;
}
webservice static Plan createAccountPlan(Plan vPlan) {
//A plan maps to the Account object in salesforce.com.
//So need to map the Plan class object to Account standard object
I. Programmatic Features – Salesforce Interview Questions
32. What is the difference between a standard controller and a custom controller?
Standard controller in Apex, inherits all the standard object properties and standard button functionality directly. It contains the same functionality and logic that are used for standard Salesforce pages.
Custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. Custom Controllers are associated with Visualforce pages through the controller attribute.
33. How can we implement pagination in Visualforce?
To control the number of records displayed on each page, we use pagination. By default, a list controller returns 20 records on the page. To customize it, we can use a controller extension to set the pageSize. Take a look at the sample code below:-
34. How can you call a controller method from JavaScript?
To call a controller method (Apex function) from JavaScript, you need to use actionfunction.
Look at the below piece of code to understand how a controller method is called using actionfunction.
1
2
3
4
5
6
<script>
function JSmethodCallFromAnyAction()
{
callfromJS();
}
</apex:page>
35. How to get the UserID of all the currently logged in users using Apex code?
You can get the ID’s of all the currently logged in users by using this global function: UserInfo.getUserId().
36. How many records can a select query return? How many records can a SOSL query return?
The Governor Limits enforces the following:-
Maximum number of records that can be retrieved by SOQL command: 50,000.
Maximum number of records that can be retrieved by SOSL command: 2,000.
37. What is an attribute tag? What is the syntax for including them?
An attribute tag is a definition of an attribute of a custom component and it can only be a child of a component tag.
Note that you cannot define attributes with names like id or rendered. These attributes are automatically created for all custom component definitions. The below piece of code shows the syntax for including them:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<apex:component>
<apex:attribute name="myValue" description="This is the value for the component." type="String" required="true"/>
<apex:attribute name="borderColor" description="This is color for the border." type="String" required="true"/>
</p>
<p>
</p>
<h1 style="border:{!borderColor}">
<apex:outputText value="{!myValue}"/>
</h1>
<p>
</p>
<p>
</apex:component>
38. What are the three types of bindings used in Visualforce? What does each refer to?
There are three types of bindings used in Salesforce:-
Data bindings, which refer to the data set in the controller
Action bindings, which refer to action methods in the controller
Component bindings, which refer to other Visualforce components.
Data bindings and Action bindings are the most common and they will be used in every Visualforce page.
39. What are the different types of collections in Apex? What are maps in Apex?
Collections are the type of variables which can be used to store multiple number of records (data).
It is useful because Governor Limits restrict the number of records you can retrieve per transaction. Hence, collections can be used to store multiple records in a single variable defined as type collection and by retrieving data in the form of collections, Governor Limits will be in check. Collections are similar to how arrays work.
There are 3 collection types in Salesforce:
Lists
Maps
Sets
Maps are used to store data in the form of key-value pairs, where each unique key maps to a single value. Syntax: Map<String, String> country_city = new Map<String, String>();
40. How can you embed a Visualflow in a Visualforce page?
Find the flow’s unique name.
From Setup, enter Flows in the Quick Find box, then select Flows.
Click the name of the flow.
Copy the unique name of the flow.
From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Pages.
Define a new Visualforce page, or open an existing one.
Add the <flow:interview> component somewhere between the <apex:page> tags.
Set the name attribute to the unique name of the flow.
For example:
1
2
3
</apex:page>
<flow:interview name="flowuniquename"/>
<apex:page>
Click Save.
Restrict which users can access the Visualforce page.
Click Visualforce Pages.
Click Security next to your Visualforce page.
Move all the appropriate profiles from Available Profiles to Enabled Profiles by using the ‘add’ and ‘remove’ buttons.
Click Save.
Add the Visualforce page to your Force.com app by using a custom button, link, or Visualforce tab.
41. What is the use of “@future” annotation?
Future annotations are used to identify and execute methods asynchronously. If the method is annotated with “@future”, then it will be executed only when Salesforce has the available resources.
For example, you can use it while making an asynchronous web service callout to an external service. Whereas without using the annotation, the web service callout is made from the same thread that is executing the Apex code, and no additional processing will occur until that callout is complete (synchronous processing).
42. What are the different methods of batch Apex class?
Database.Batchable interface contains three methods that must be implemented:
Start method: global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext bc) {}
Execute method: global void execute(Database.BatchableContext BC, list<P>){}
Finish method: global void finish(Database.BatchableContext BC){}
43. What is a Visualforce component?
A Visualforce Component is either a predefined component (standard from component library) or a custom component that determines the user interface behavior. For example, if you want to send the text captured from the Visualforce page to an object in Salesforce, then you need to make use of Visualforce components. Example: <apex:detail>
44. What is Trigger.new?
Triger.new is a command which returns the list of records that have been added recently to the sObjects. To be more precise, those records will be returned which are yet to be saved to the database. Note that this sObject list is only available in insert and update triggers, and the records can only be modified in before triggers.
But just for your information, Trigger.old returns a list of the old versions of the sObject records. Note that this sObject list is only available in update and delete triggers.
45. What all data types can a set store?
Sets can have any of the following data types:
Primitive types
Collections
sObjects
User-defined types
Built-in Apex types
46. What is an sObject type?
An sObject is any object that can be stored in the Force.com platform database. Apex allows the use of generic sObject abstract type to represent any object.
For example, Vehicle is a generic type and Car, Motor Bike all are concrete types of Vehicle. In SFDC, sObject is generic and Account, Opportunity, CustomObject__c are its concrete type.
47. What is the difference between SOQL and SOSL?
The differences are mentioned in the table below:
SOQL vs SOSL
SOQL (Salesforce Object Query Language)
SOSL (Salesforce Object Search Language)
Only one object can be searched at a time
Many objects can be searched at a time
Can query any type of field
Can query only on email, text or phone
Can be used in classes and triggers
Can be used in classes, but not triggers
DML Operation can be performed on query results
DML Operation cannot be performed on search results
Returns records
Returns fields
48. What is an Apex transaction?
An Apex transaction represents a set of operations that are executed as a single unit. The operations here include the DML operations which are responsible for querying records. All the DML operations in a transaction either complete successfully, or if an error occurs even in saving a single record, then the entire transaction is rolled back.
49. What is the difference between public and global class in Apex?
Global class is accessible across the Salesforce instance irrespective of namespaces. Whereas, public classes are accessible only in the corresponding namespaces.
50. What are getter methods and setter methods?
Get (getter) method is used to pass values from the controller to the VF page. Whereas, the set (setter) method is used to set the value back to controller variable.
Change Sets
We use change sets to send customizations from one Salesforce org to another.
When we want to send customizations from our current org to another org,
- we create an outbound change set.
Once we send the change set,
- the receiving org sees it as an inbound change set.
Sending a change set between two orgs requires a deployment connection.
- Change sets can only be sent between orgs that are affiliated with a production org
Usually used for a small number of component migration.
Connection between the orgs has to be manually established, so it isn’t suitable for automated deployments.
Doesn’t allow destructive changes.
I make sure 'backups' are done - before the realeaseupdates..
- just in case something does not work - we can rollback..
RULE-1
Can we edit in Production.
- We can edit apex class in only Enterprise Edition of Salesforce.
- Ideally, we do not make any changes in Productions.
All Changes should be made in a Sandbox then deployed - without exception
- Sometimes (VERY Rare cases) - If changes are minor change in production.
- copy the same code to the sandbox it self.
- But then, AGAIN - We should NOT allow any 'Manual' changes to Production box
What is with sharing and without sharing? How general class mode will run?
- If you declare a class as a With Sharing,
Sharing rules given to the current user will be taken into the consideration
and the user can access or perform the operations based on
the permissions given to him on object and fields (Field Level Security, Sharing rules).
- If you declare a class as a Without Sharing,
then this Apex class runs in system mode which means Apex code has
access to all the objects and field irrespective of current
users sharing rules, field level security and Object permissions.
If the class is not declared as With Sharing or Without Sharing
- then the class is by default taken as With Sharing.
What is the Difference between system mode and user mode?
Explain me a case of how sales cloud work on with the flow of objects?
What is the use of global keyword, what happens if we do not give?
What are Web to lead, web to case and escalation rules?
Extension classes, use, limits, purpose and their order?
Can we use both standard controller and custom controller together?
What is standardSetController, why we use it?
About Pagination using standard and custom controllers? How you do it?
What is the no. of records can be displayed on visualforce page, and how to maximize it?
Difference between render and rerender?
Render: – Is used to show/hide the particular block, output panel or
- input/output fields based on the condition.
Example: – You have 2 fields one is visible and second is hidden,
you want the second field to be visible when the first field is filled then use render.
ReRender : Is used to refresh the particular output panel, block, and or fields
- after a server request has been completed.
- It uses 'Id' to reRender.
renderAs: – Is used to open the Visualforce Page in different format like- HTML, pdf, and excel
What is the use of apex action status? Can you give me an example?
What is the difference between action function and @Remote action?
@Remote action?
Remote Action can call the apex methods from any apex class.
Remote Action allows you to call the method from javascript
-- and retrieve the result as a javascript object for manipulation.
Remote Action methods are static and global,
-- hence don’t have access to your current controller variables and methods.
https://www.biswajeetsamal.com/blog/difference-between-remote-action-and-action-function-in-salesforce/
Action Function is a Visualforce tag allows you to invoke
- a controller action from the Visualforce Page asynchronously via AJAX requests
Action Function methods are instance methods,
- and so can see the entire page state
What is the use of Action support and apex:facet?
How to load the javascript or css existing? Where to load them? Can you tell me the syntax?
What is the Use of custom labels, how do you access them in apex classes and in visualforce pages?
How to add error on visualforce page through apex class and through visualforce page?
How to add error through the trigger?
What the common deployment issues you know?
What are the best practices you follow and how is your thought process keeping the governor limits in mind to write trigger/classes?
How would you approach to write a test class? What are the best practices?
What is @testSetup? And it’s purpose? And how many we can have in a single test class?
Use test setup methods (methods that are annotated with @testSetup)
- to create test records once and
- then access them in every test method in the test class.
Test setup methods are time-saving when you need to create reference
- or prerequisite data for all test methods,
- or a common set of records that all test methods operate on.
@isTest
private class CommonTestSetup {
@testSetup static void setup() {
// Create common test accounts
List testAccts = new List();
for(Integer i=0;i<2;i++) {
testAccts.add(new Account(Name = 'TestAcct'+i));
}
insert testAccts;
}
@isTest static void testMethod1() {
// Get the first test account by using a SOQL query
Account acct = [SELECT Id FROM Account WHERE Name='TestAcct0' LIMIT 1];
// Modify first account
acct.Phone = '555-1212';
// This update is local to this test method only.
update acct;
// Delete second account
Account acct2 = [SELECT Id FROM Account WHERE Name='TestAcct1' LIMIT 1];
// This deletion is local to this test method only.
delete acct2;
// Perform some testing
}
@isTest static void testMethod2() {
// The changes made by testMethod1() are rolled back and
// are not visible to this test method.
// Get the first account by using a SOQL query
Account acct = [SELECT Phone FROM Account WHERE Name='TestAcct0' LIMIT 1];
// Verify that test account created by test setup method is unaltered.
System.assertEquals(null, acct.Phone);
// Get the second account by using a SOQL query
Account acct2 = [SELECT Id FROM Account WHERE Name='TestAcct1' LIMIT 1];
// Verify test account created by test setup method is unaltered.
System.assertNotEquals(null, acct2);
// Perform some testing
}
}
What is your approach during peer code review?
What is the difference between dataloader and import wizard?
Methods in batch class, sIterable and getquereyloacator differences?
How to invoke batch class from another batch class?
What happens if i invoke batch class form execute method other than finish method?
Scope of database.batachable interface?
Can i have a class implementing interface, methods not implementing interface? Can i have methods along with interface methods and other new methods also?
How can you deploy other than using change sets? What is difference?
- Krish
- Venkat
Looking for Developement and configuration
Custom Code
--> Custom Settings
We use custom settings to create and manage custom data at
- the organization, profile, and user levels.
Custom settings data is stored in the application cache.
Custom settings are similar to custom objects and
- enable developers to create custom sets of data,
- as well as create and associate custom data
- for an organization, profile, or specific user.
----------------------------------------------------------------------------------
Classic Email Templates
Lightining email templates
Mail Merge Templates
We can create TEXT, HTML, Custome or Visualforce templates
Using visualforce page in PageLayout -
Yes we can use -
On Page Layout - there is an option called "Custom Console Components"
- Custom console components are Visualforce pages that customize or extend a console.
- Add components to page layouts so that users can access customizations
----- when they view specific pages in a console.
- You can also add components to a console app
----- so that users can access customizations that span
----- across all pages and tabs in a console.
can we embbed a visual page
- in a page layout..
on home page 'yes'..
on page layout
- then I can create a 'visual-flow' using flow budiler
- but not not sure of visuaf page
-----------------------------------------------------------------------
Lands' End is an clothing & home decor retailer store
in Dodgeville, Wisconsin
- that specializes in casual clothing, luggage, and home furnishings.
Demandware or Salesforce Commerce Cloud,
- Primerly used for "Order Management"
is basisclly used at Storefront.
I have seen couple of it's objects like..
- Basket - Represents a shopping cart.
- Campaign
- Category - product catalog and contains attributes that contain category data
- Content
B2B e-commerce is simply commerce between companies.
various e-commerce concepts like..
- business-to-business (B2B)
- business-to-consumer (B2C)
- business-to-government (B2G)
- consumer-to-consumer (C2C)
- mobile commerce (m-commerce).
Logistics - transportation, warehousing and distribution (e.g., Procter and Gamble);
Application service providers - deployment, hosting and management of packaged software from a central facility (e.g., Oracle and Linkshare);
Web-based commerce enablers (e.g., Commerce One, a browser-based, XML-enabled purchasing automation software).
Content management software for the facilitation of Web site content management and delivery (e.g., Interwoven and ProcureNet); and
Functions in the process of e-commerce, such as Web-hosting, security and customer care solutions (e.g., outsourcing providers such as eShare, NetSales, iXL Enterprises and Universal Access);
Auction solutions software for the operation and maintenance of real-time auctions in the Internet (e.g., Moai Technologies and OpenSite Technologies);
Single Sign-On
Single sign-on (SSO) lets users access authorized network resources with one login. You validate usernames and passwords against your corporate user database or other client app rather than Salesforce managing separate passwords for each resource.
https://www.salesforce.com/blog/2018/12/spring-19-release-sandbox-preview-instructions.html
Salesforce Spring ’19 Release Notes
- More Tools to Adopt Lightning Experience and Boost Productivity
- AI-Driven Insights in Reports, Joined Reports in Lightning Experience
https://developer.salesforce.com/forums/?id=9060G000000XgRyQAK
User Mode and system Mode
1. What is the difference between a role and a profile?
Role/Role hierarchy determines record access in a private data sharing model
determines record access/visibility
Roles are Optional.
If you are using hierarchy sharing, roles play an important part.
Profile determine
- What parts of the application a user can see
- Object permissions
- Page layouts
- Field level security
3. How many profiles one user can have in Salesforce?
1 (one)
4. What is Sandbox?
Initial Environment of Salesforce where Developers create custom object.
5. Explain custom object in Salesforce
Any Object that is not given as part of Salesforce (that we create on our own is called a custom object)
8. What’s the difference between Record Types & Page Layouts
'Record types' are used to display different 'page layouts'
and 'picklist values' for different types of 'records'.
When defining Record Types - you can
- Select Page layouts.
- Define different picklist values
- and Select Paths
Record Types can be assigned to profile
Object’s visual representation is called 'page layout '
You can do several things while designing Page Layouts
Example
-- Make fields required
-- Make fields read-only
9. What options are available to you for deploying from a Sandbox to Production?
we can simply use ChangeSets and do the deployment manually
I have come across several tools for Release Management
• SalesforceDX
• AutoRabbit
• GearSet
10. Can you customize Apex & Visualforce directly in a production org?
- We can edit apex class in only Enterprise Edition of Salesforce.
- Ideally, we do not make any changes in Productions.
All Changes should be made in a Sandbox then deployed - without exception
- Sometimes (VERY Rare cases) - If changes are minor change in production.
- copy the same code to the sandbox itself.
- But then, AGAIN - We should NOT allow any 'Manual' changes to Production box
---------------------------------------------------
(FSL)
Field Service Lightning
Field Service Lightning is a powerful, highly customizable set of features that you can use to set up a mobile-friendly field service hub in Salesforce.
- Manage Work Order
- Manage Inventory
- Optimize Schedule
- Manage Service Reports
Assignments
Add a custom field to standard object
- add it to work flow
- try removing the field
- remove from work flow
- remove the custom field
(See what happens in the page layout)
//will refer to base 'class'
.THIS {
background-color:yellow;
}
//will refer to 'class' called 'red'
.THIS .red{
color:red;
}
-----------------------------------------------------------------
Application vs Component --> Application Style is taken
but you can override to use component style by using '!important';
// $A.enqueueAction adds the server-side action to the queue.
$A.enqueueAction(action);
-----------------------------------------------------------------
Bound and unbound expression
-- {!v} Bound Expression (Loosly Coupled)
-- {#v} Unbound Expression
-- If you are working on parent-child components
-- and if you do not want parent to change the values of child attributes
-- or child to change the values of parent attributes,
-- then we use !v or #v
-- !v you can change values
-- #v you CANNOT Change values
------------------------------------
SecuritiesExplorer
Object : BondStock__c
--------------------------------------
BondStock Name (Beer Name) - Text(80)
Tags - Text(80)
Profit % (Alcohol %) - Percentage (5,2)
Id - Text(10)
Company_id (brewery_id) Text(10)
Company_Name - Text(255)
Image - URL
Total Quantity - Number (5,0)
Remaining Quantity - Number (5,0)
Price Currency (5,0)
Object : SB_Order__c
--------------------------------------
Order Number (Auto Number) - ORD- 0000)
BondStock - "Lookup BondStock__c"
Order Quantity
Status (Piclist (New, Submitted, InProcess, Delivered)
Order Amount (Currency 5,2)
Order By - "Lookup user"
Ship-to-City
Bill-to-City
------------------------------------
Error Handling
-- Server Side errors can be handled by..
Difference between insert() & Database.insert()
Using insert method we can insert the records but if any error occurs in any record system will throw an error insertion fail and none of the records are inserted.
If we want to execute partially success of bulk insert operation we will use database .insert.
Ways to share the record
Role Hierarchy:
If we add a user to a role, the user is above in the role hierarchy will have read access. Setup -> manage users -> roles -> setup roles -> click on ‘add role’ -> provide name and save.
Manual Sharing:
Manual Sharing is sharing a single record to single user or group of users. We can see this button detail page of the record and this is visible only when OWD setting is private.
Criteria Based Sharing rules: If we want to share records based on condition like share records to group of users Whose criteria are country is India. Setup -> security controls -> sharing settings -> select the object and provide name and Conditions and save
Apex sharing:
Share object is available for every object(For Account object share object is AccountShare ). If we want to share the records using apex we have to create a record to the share object.
Maximum size of the PDF generated on visualforce attribute renderAs:
15 MB
How many controller can be used in VF page:
Salesforce come under SAAS so, we can use one controller and as many extension controllers.
Transfer Records in profile
If user have only Read access on particular record but he wants to change the owner name of that record, then in profile level Transfer Record enables he can able to change the owner.
Difference between Export & Export All in data loader
Export enables user to export all the records for a particular object excluding the records in the recycle bin or soft deleted records.
Export All enables user to export all the records for a particular object including the records in the recycle bin or soft deleted records.
What is WSDL?
Enterprise WSDL
1. The Enterprise WSDL is strongly typed.
2. The Enterprise WSDL is tied (bound) to a specific configuration of Salesforce (ie. a specific organization's Salesforce configuration).
3. The Enterprise WSDL changes if modifications (e.g custom fields or custom objects) are made to an organization's Salesforce configuration.
For the reasons outlined above, the Enterprise WSDL is intended primarily for Customers.
Partner WSDL
1. The Partner WSDL is loosely typed.
2. The Partner WSDL can be used to reflect against/interrogate any configuration of Salesforce (ie. any organization's Salesforce configuration).
3. The Partner WSDL is static, and hence does not change if modifications are made to an organization's Salesforce configuration.
For the reasons outlined above, the Partner WSDL is intended primarily for Partners.
Download a WSDL file when logged into Salesforce
1. Click Setup | Develop | API
2. Click the link to download the appropriate WSDL.
3. Save the file locally, giving the file a ".wsdl" extension.
What is SOAP?
SOAP is defined as an XML-based protocol.
It is known for designing and developing web services as well as enabling communication between applications developed on different platforms using various programming languages over the Internet.
It is both platform and language independent.
How you will make a class available to others for extension? (Inheritance concept)
The class has to be either abstract or virtual in order to extend it.
A class that extends another class inherits all the methods and properties of the extended class.
In addition, the extending class can override the existing virtual methods by using the override keyword in the method definition.
Overriding a virtual method allows you to provide a different implementation for an existing method.
This means that the behavior of a particular method is different based on the object you’re calling it on. This is referred to as polymorphism.
A class extends another class using the extends keyword in the class definition. A class can only extend one other class, but it can implement more than one interface.
This example shows how the YellowMarker class extends the Marker class. To run the inheritance examples in this section, first create the Marker class.
public virtual class Marker {
public virtual void write() {
System.debug('Writing some text.');
}
public virtual Double discount() {
return .05;
}
}
// Extension for the Marker class
public class YellowMarker extends Marker {
public override void write() {
System.debug('Writing some text using the yellow marker.');
}
}
In the process of creating a new record, how you will check, whether user has entered email or not in the email field of Account object?
Validation Rule (ISBLANK(Email__c)) or Trigger with before event.
trigger CheckName on Account (before insert)
{
List a1=[Select id from account where account.name=:trigger.new[0].name];
if(a1.size()>0)
{
trigger.new[0].name.addError('Account Name already Exist');
}
}
How you will write a javascript function that display an alert on the screen?
Whatis the value of “renderas” attribute to display o/p in the form of Excel Sheet?
How you will get the javascript function into Visualforce page?
1. You can then use the functions defined within that JavaScript file within your page using