Using point and click approach, we can configure the functionalities.

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 -

  1. Task: Task is nothing but work assigned to a particular person, it doesn't have certain time limit.
  2. 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.

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.

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.

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.

Within the sfdc standered functionality (no need to code).

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.

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.

text, number, auto number, email.

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.

On the detail page without clicking on edit button we can edit particular field if it is not read-only.

To enable or disable Inline editing follow the below navigation - Setup--> Customise--> User Interface--> Enable Inline Editing

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.

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 -

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.

To control the picklist values of the status field on the lead object we should create lead process.

To control the picklist values of the stage field on the opportunity object we should create sales process.

To control the picklist values of the status field on the case object we should create support process.

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.

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.

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.

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.

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.

On case object we can create Escalation rule. Based on the priority we can send escalation mails.



answer

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

No, once we create an user in salesforce we cannot delete the user record. We can only deactivate the user record.

If we enable 'Grant Account Login Access' for a user then we can see 'Log in' button on the detail page of that user. By clicking on that 'Log in' button without giving that user's username and password we can log in.

To enable the 'Grant Account Login Access' follow the below steps -

  1. Log in as a user to whom you want to enable Log in access.
  2. At top right corner click on name (Which should be left to Setup) > My Settings
  3. User should be able to see user's personal set up page.
  4. Left side, click on Personal Information > Grant Account Login Access
  5. User should be able to see Grant Account Login Access page
  6. In Access Duration column select '1 Year' for all the records and click on 'Save' button.
  7. Log out and Log in as any other user in the organization then click on Manage Users > Users.
  8. User should be able to see list of records and verify the user to whom we enabled the Grant Account Login Access
  9. User should be able to see the Login link beside Edit link.
  10. Click on Login then user should be able to login as that user mode
  11. Observe at top right corner, user should be able to see Logged in as 'Name of the user' which should be highlighte in black color.
  12. Click on Logout
  13. User should be come back to original user's mode, Observe at top right corner, user should not be able to see Logged in as 'Name of the user'

Using Profiles and Permission Sets.

Permission sets.

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)

  1. OWD(Organigation Wide Defaults) / Private/PublicRead/PublicWrite
  2. Profiles
  3. Roles (Veritical Sharing)
  4. Sharing Rules (Horizontal Sharing)
  5. Manual Sharing (Horizontal Sharing)
  6. Apex Managed sharing
  7. View all.
  8. Modify all.
  9. View all data.
  10. Modify all data.

Role deals with authorization to access data.

OWD is the default access level on records for any object in sales force.
For custom objects we can see below access levels -

  1. Private
  2. Public Read only
  3. Public Read/Write
By default after creating custom object OWD access level is Public Read/Write.

Private: only owner and above hierarchy users can have Read/Write access and below hierarchy users don't have any access.
Public Read only: only owner and above hierarchy users can have Read/Write access and below hierarchy users can have only Read Only.
Public Read/Write: Irrespective of role hierarchy every one can have Read/Write permissions on the records.

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

Say there are three roles

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.

To process bulk records.

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.

  1. Insert (Inserting brand new records, no need of ID)
  2. Update (Updating the existing records based on the record ID)
  3. 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)
  4. Delete (Delete the records based on the id provided, to delete we need only id, deleted records can be found in recycle bin)
  5. 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.)
  6. 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)
  7. 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)

.CSV (Comma Separated Values)

.SDL

In dataloader settings we should enable 'insert null values' checkbox otherwise we can't insert null values.

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.

10,000 records and minimum 1 record.

2,000 records.

To perform the automated actions.

  1. Created
  2. Created and everytime edited to meet the criteria
  3. 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' -

  1. 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)
  2. 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.

  1. 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 )
  2. 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)

The action which will be performed immediately after the record criteria meets.

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.

Created and everytime edited to meet the criteria.

  1. 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)
  2. New email alert (we can send emails if the criteria meets)
  3. New task (we can create new task)
  4. New outbound Message (we can make a callout)
  1. Text
  2. HTML (with letter head)
  3. Custom HTML (without letter head)
  4. Visual Force

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.

Yes, It will trigger in scheduled date.

It won't fire. To fire wf2 we should enable 'Re-evaluate Workflow Rules' checkbox of the field update which is there in wf1.

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 -

  1. 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.
  2. If you don't enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update of a workflow rule we can avoid.

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)

Before creating the Approval Process we should select the object after that we should follow below steps -

  1. Give the Approval Process name
  2. Give the criteria of the Approval Process
  3. 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)
  4. 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)
  5. Select the user to whom record should be submitted
  6. Initial submission actions ( after submitting the record for approval immediately whatever the actions included in the initial submission actions section will be triggered)
  7. Approval Steps (we can add multiple steps)
  8. For each and every step we can see 'Approval actions' and 'rejection actions' sections where we can add actions to be performed
  9. If the Approver approves the record then actions which are under 'approval actions' section will be triggered
  10. Final approval actions section (If all the steps approved then actions which are under 'final approval actions' section will be triggered)
  11. Final rejection actions section (If any one of the step rejected then actions which are under 'final rejection actions' section will be triggered)
  12. 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 )

It’s not possible, to add one more step deactivate the approval process and clone the deactivated approval process and add the new steps.

To summarize the information.

To summarize the information of an object we use reports.

  1. Tabular (Displays records just like a table)
  2. Summary (we can summarize the information based on certain fields)
  3. Matrix (we can summarize the information in two dimensional manner, both rows and columns)
  4. Join (we can summarize information in different blocks on the same object and the related objects)

5 blocks.

3 groupings

Bucket field in Reports is used to group values to the name we specify.

See in detail here

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

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];
    

Questions on Apex Triggers.

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.

To capture the runtime information we use trigger context variables.

Below context variables will return either true or false.
  1. Trigger.isBefore (returns true if the trigger context is Before Mode)
  2. Trigger.isAfter (returns true if the trigger context is After Mode)
  3. Trigger.isInsert (returns true if the trigger context is Insert)
  4. Trigger.isUpdate (returns true if the trigger context is Update)
  5. Trigger.isDelete (returns true if the trigger context is Delete)
  6. Trigger.isUndelete (returns true if the trigger context is Undelete)
  7. Trigger.isExecuting (returns true if the apex class method is getting call from Apex Trigger)
Below context variables will store records at runtime.
  1. trigger.old (stores history (old versions) of the records.)
  2. trigger.oldMap (stores history (old versions) of the records along with id.)
  3. trigger.new (stores new version of the records.)
  4. trigger.newMap (stores new version of the records along with id.)
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
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
Before Triggers
  1. To perform the validations we should use before triggers.
  2. 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
  1. 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).

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.

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.

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.
   }
  }
   

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;
   }
    

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:
  1. Prepare the record for insert/update operation.
  2. It will replace all the old field values with new field values.
  3. If the request is coming form UI all the system validations will execute -
    • DataType
    • Length
    • Required
    • unique
    • pageLayot level validations
  4. before triggers
  5. Custom Validations and again system validation rules will fire (pageLayot level validations won't fire at this point of time).
  6. record will be saved into the database but doesn't not commit.
  7. after triggers.
  8. assignment rules.
  9. auto-responsive rules.
  10. Workflow Rules
  11. incase of Workflow Rule Field updates again before triggers and after triggers fire one more time. System validation ruels for duplicate chcek.
  12. Escalatoin Rules.
  13. Rollup-Summary fields will be calculated.
  14. Grant parent Rollup-Summary fields will be calculated.
  15. Criteria base sharing evaluation.
  16. Record will be commited into the database.
  17. Post Commit logic (Sending emails).

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).

It will throw the validation error because after the workflow field update before triggers fire one more time.

Questions on 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.

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 -

  1. start: It will prepare the records to process and execute only one time.
  2. 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.
  3. 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);*/
   }
  }
   

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.
   }
  }
    

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.

   /*** 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);
  

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.

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.

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.

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();
   

Up to 5 batch jobs can be queued or active.

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.

Questions on Test Classes.

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.

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.

  @isTest
  private class MyTestClass {
    
    static testMethod void myTest1() {
    }
    
    static testMethod void myTest2() {
    }
    
  }
    
Note: Test Class can be either public or private.

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.

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().

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().

What is the purpose?

To compare Actual value and Expected value we use assert statements.

Types of assert statements

  1. system.assertEquals(val1,val2): If both val1 and val2 are same then test class run successfully otherwise test class will fail.
  2. system.assertNotEquals(val1,val2): If both val1 and val2 are not same then test class run successfully otherwise test class will fail.
  3. system.assertEquals(val1> val2): If the condition satisfied then test class run successfully otherwise test class will fail.

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())

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.

  1. 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.
  2. While testing apex triggers and batch classes, we should do bulk testing at least with 200 records.
  3. We should test for all the positive and negative scenarios.

Questions on Web Services.

preparing...

preparing...

Do you have any queries mail me at: srinu@srinusfdc.com

Questions on 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 -

  
   
  
    

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.

There are the two types of controllers -

  1. Standard Controller
  2. 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 -

  1. extensions
  2. Standard List Controller
  3. 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.

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.

  1. Creation: In a visualforce page, whenever we use form tag then view state will be created for the page.
  2. 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.
  3. 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.
  4. Governor Limits: Maximum size of the View State is: 135 KB.
  5. Page Performance:
    1. 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.
    2. Static variables also won't occupy space in the view state.
    3. 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.

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')

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.

On VF page we should use -

    
   

In Apex Class, we should use -

    ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error,'Error Message'));
   

Note: For the standardController no need to include code inside of the Apex Class.

Following severity levels are available -

  1. CONFIRM

  2. ERROR

  3. FATAL

  4. INFO

  5. WARNING

Click here for the reference

on a standardController page to display the multiple records we use recordSetVar (without the support of any extensions class).

dataTable: Display the records without standard salesforce look and feel.

pageBlockTable: Display the records with standard salesforce look and feel.

1000

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

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.

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.

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 -

  1. Using standardSetController
  2. Using Limit and Offset keywords in SOQL query.

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.

There are two types of custom settigns -

  1. List Custom Settings
  2. Hierarchy Custom Settings

List custom settings -

  1. List Custom Settings are like custom objects.
  2. We can create the fields and we can store the records.
  3. List Custom Settings records will store in Application Cache memory.
  4. To access List Custom Settings records no need to use SOQL query.
  5. 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 -

  1. We can add users and profiles.
  2. After that we can check that a particular/current logged in user is part of this custom settings.
  3. We can refer this in below components -
    1. Validation Rules
    2. Apex Classes and Apex Triggers
    3. Visualforce Pages

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.

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.

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.

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.

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.

Parameters Example: /apex/SamplePage?param1=val1&param2=val2

  1. ?param1=val1 : parameters should start with ? symbol.
  2. &param2=val2 : To add multiple parameters, each parameter should be separated with & symbol.

Ways of passing parameters -

  1. 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
       
  2. 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');
       
  3. 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.
  4. 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.

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.

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?

  1. If you want to reuse the VF page logic.
  2. If the VF page logic is huge and if you want to split into different pieces.

We can request VF page in two ways -

  1. Get Request: Whenever we click on a link or button or directly hitting the url in address bar we can open a VF page.

    Get Request Order
  2. Postback Request: On a VF page after populating fields if you click on save button certain action will invoke it is nothing but postback request.

    Postback Request Order

Ajax Functions

Preparing.

Preparing.

Preparing.

Preparing.

Preparing.

<apex:page standardController="obj__c" recordSetVar="records">
<apex:form>
<apex:pageblock title="Records">
<apex:variable var="count" value="{!1}"/>
<apex:pageblockTable value="{!records}" var="rec">
<apex:column headerValue="S.No">
{!count}
<apex:variable value="{!count+1}" var="count"/>
</apex:column>
<apex:column value="{!rec.A__c}"/>
<apex:column value="{!rec.B__c}"/>
<apex:column value="{!rec.C__c}"/>
</apex:pageblockTable>
</apex:pageblock>
</apex:form>
</apex:page>
view raw ShowDataVfPage hosted with ❤ by GitHub
Do you have any queries mail me at: srinu@srinusfdc.com

Scenarios on Apex Triggers.

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).


Solution

  1. /* Description:
  2. * ============
  3. * Apex Trigger to delete the related child object records upon
  4. * deleting the parent object record in case of look up
  5. * relationship *
  6. * Author:
  7. * ========
  8. * www.srinusfdc.com
  9. */
  10. trigger ParentTrigger on Parent__c (before delete) {
  11.     /*Assume that parent__c is a field api name( look up to parent object) in child object.*/
  12.     delete [select id from Child__c where parent__c in: trigger.old];
  13.     /*Note: trigger.old will be automatically converted to set of ids
  14.     by salesforce (alternative: trigger.oldMap.keyset()).*/
  15. }

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.
2 Create New Custom Object
Singular Label: Parent
Plural Label: Parents
Object Name: Parent

Standard Field:
Field Label Parent No:
Data Type: Auto Number
Display Format: P-{00000}
3 Create New Custom Object
Singular Label: Child
Plural Label: Childs
Object Name: Child

Standard Field:
Field Label Child No:
Data Type: Auto Number
Display Format: C-{00000}
4 preparing...

Salesforce Online Training: srinu.ind19@gmail.com/srinu@srinusfdc.com | Whats App: +91-8087988044 | Course Details: onlinetraining.srinusfdc.com

Simple Apex Programs for practice.

public class RemoveWhiteSpace {
public String remvoeWhiteSpaceFromString(String strVal) {
return strVal.deleteWhitespace();
}
}
view raw RemoveWhiteSpace hosted with ❤ by GitHub
 /***
 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
 ***/

   
public class Fibonacci {
public String getnerateFibbonaci(Integer num) {
String fibobonaciSeries = 'Fibonacci Series: ';
Integer f1 = 0, f2 = 1, nextNum = 0;
for(Integer i=0;i<num;i++) {
nextNum = f1 + f2;
f1 = f2;
f2 = nextNum;
fibobonaciSeries += ', '+String.valueOf(nextNum);
}
}
return fibobonaciSeries;
}
}
view raw Fibonacci hosted with ❤ by GitHub
/***
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

***/
  
public class LeapYear {
public Boolean isLeapYear(Integer year) {
Boolean isTrue = false;
if ( math.mod(year,400) == 0 || math.mod(year,4) == 0)
isTrue = true;
return isTrue;
}
}
view raw LeapYear hosted with ❤ by GitHub
/***
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


  
public class SwapNumbers {
public void doNumSwapping(Integer a, Integer b) {
a = a + b;
b = a - b;
a = a- b;
system.debug('a value: '+a);
system.debug('b value: '+b);
}
}
view raw SwapNumbers hosted with ❤ by GitHub
/***
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?

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?

Q4) How Does Apex Work?

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:

Q6) What is Map Class in Apex Salesforce?

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: 

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.

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?

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:

1. Insert
2. Update
3. Delete
4. Merge
5. Upsert
6. Undelete

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.

Q15) Adding Flows to Visualforce Pages

<apex.page>
<apex:sectionheader subtitle="“verification”/" title="”userlogin”">
<flow:interview name="“usertest”"></flow:interview>
</apex:sectionheader></apex.page>

Q16) What is Apex Managed Sharing?

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 “ >

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 &#39;map*&#39; In ALL FIELDS RETURNING Account (ID, Name), contact, opportunity, lead ];

Note

Example:

FIND &#39;map*&#39; 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.

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]
                       );

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)?

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

Trigger

Q44) Difference between SOQL Vs SOSL in salesforce?

SOQL- Salesforce Object Query Language

SOSL(Salesforce object Search Language)


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:

OWD can be Private, Public Read Only, Public Read and Write.

Setup -> Security Controls -> sharing settings -> Click on ‘Edit’

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.

ALL validation rules set up have the &&

$Setup.CustomSetting__c.ValidationRuleEnabled__c added.

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:

Controllers:

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.

Disadvantages of batch processing:

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

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:

MOD(DATEVALUE( Date_Field__c ) – DATE(1985,7,1),7)

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.

Q86) What are the actions in workflow?

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?

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 to update the Account description before inserting a record

    trigger addDescr on Account (before insert) {
    for(Account account : Trigger.new) {
    account.Description = 'Account created by King Koduru';
    }
    }

    Testing:
    Account account = new Account(Name='ContactNew3');
    insert account;


    _______________________________________________________________________________

    // Trigger to Update the description field on Contact object, before update

    trigger ContactBeforeUpdate on Contact (before update) {
    for(Contact c : Trigger.new) {
    c.description = 'Contact updated by' + userInfo.getUserName();
    }
    }



    _______________________________________________________________________________

    // You can have multiple Trigger events in one Trigger.

    trigger ContactBeforeInsertUpdate on Contact (before insert, before update) {
    for(Contact c : Trigger.new) {
    if(trigger.isInsert{
    c.description = 'Description updated upon Insert';
    }
    else if(trigger.isUpdate{
    c.description = 'Description updated upon Update';
    }

    }
    }




    _______________________________________________________________________________

    // 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.

    multi tenant architecture - salesforce interview questions

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

    sample visualforce page - salesforce interview questions

    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 only access 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:-

    TextAll users can create or change this template
    HTML with letterheadOnly Administrators and users having “Edit HTML Templates” permissions can create this template based on a letterhead.
    Custom HTMLAdministrators and users having “Edit HTML Templates” permissions can create this template without the need of a letterhead
    VisualforceOnly 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 reportsSimple Excel type tables which provide a list of items with the grand total
    2. Summary reportsSimilar to Tabular reports, but also have functionality of grouping rows, viewing subtotals & creating charts
    3. Matrix reportsTwo-dimensional reports which allow you to group records both by row and column
    4. Joined reportsMultiple 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:

    1. Change Sets
    2. Eclipse with Force.com IDE
    3. Force.com Migration Tool – ANT/Java based
    4. 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
     Account acct = new Account();
     acct.Name = vPlan.name;
     acct.AccountNumber = String.valueOf(vPlan.planNumber);
     insert acct;
     vPlan.planId=acct.Id;
     return vPlan;
     } }

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

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    <apex:page standardController="Account" recordSetvar="accounts">
     <apex:pageBlock title="Viewing Accounts">
     <apex:form id="theForm">
     <apex:pageBlockSection >
     <apex:dataList var="a" value="{!accounts}" type="1">
     {!a.name}
     </apex:dataList>
     </apex:pageBlockSection>
     <apex:panelGrid columns="2">
     <apex:commandLink action="{!previous}">Previous</apex:commandlink>
     <apex:commandLink action="{!next}">Next</apex:commandlink>
     </apex:panelGrid>
     </apex:form>
     </apex:pageBlock>
    </apex:page>

    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?

    1. Find the flow’s unique name.

      1. From Setup, enter Flows in the Quick Find box, then select Flows.
      2. Click the name of the flow.
      3. Copy the unique name of the flow.
    2. From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Pages.

    3. Define a new Visualforce page, or open an existing one.

    4. Add the <flow:interview> component somewhere between the <apex:page> tags.

    5. Set the name attribute to the unique name of the flow.

    For example:

    1
    2
    3
    </apex:page>
    <flow:interview name="flowuniquename"/>
    <apex:page>
    1. Click Save.

    2. Restrict which users can access the Visualforce page.

      1. Click Visualforce Pages.
      2. Click Security next to your Visualforce page.
      3. Move all the appropriate profiles from Available Profiles to Enabled Profiles by using the ‘add’ and ‘remove’ buttons.
      4. Click Save.
    3. 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:

    1. Start method:
      global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext bc) {}
    2. Execute method:
      global void execute(Database.BatchableContext BC, list<P>){}
    3. 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 timeMany objects can be searched at a time
    Can query any type of fieldCan query only on email, text or phone
    Can be used in classes and triggersCan be used in classes, but not triggers
    DML Operation can be performed on query resultsDML Operation cannot be performed on search results
    Returns recordsReturns 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.




    --------------------------------------------------------------------------------

    Make a custom field a required field
    - There many ways to make custom fields required

    1) At Field level requirements

    - We can make it "required" when defining the field itself.

    2) On the page layout

    - We can make this field "Required" on specific page layouts
    - So some users that use a particular page layout but not others.

    3) Write a Validation rule requirement using ISBLANK or ISNULL function..

    - ISBLANK(Custom_Field)
    - ISNULL(Custom_Field)

    4) Write a BEFORE-INSERT-TRIGGER
    - Fire a Trigger (Before Insert Trigger)


    --------------------------------------------------------------------------------


    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

    Re: Creating Change Sets..
    https://www.youtube.com/watch?v=qU7xfExeo90


    ----------------------------------------------
    Change Sets Disadvantages

    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.



    ----------------------------------------------



    https://help.salesforce.com/articleView?id=000213655&type=1

    Code coverage steps before deployment


    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



    ----------------------------------------------------------

    I have used JSON format for REST Services,
    but RESTful web services - permits Text, HTML, XML or JSON formats

    ----------------------------------------------------------



    https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/intro_framework.htm


    More of Lighting
    Apex

    Migration to Lighting..AMEX



    --------------------------------------------------------------------------------------------------------

    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?


    5pm EST

    https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode

    - 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


    ----------------------------------------------------------------------------------

    SeeAllData.
    Using Limits, startTest, and stopTest

    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);

    -----------------------------------------------------------------------




    Get this good picture..
    https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_and_actions.htm


    SNP Global
    How many years - Salesforce Admin
    Triggers

    application/code security issue
    best practices
    test systems using automation
    Trigger Frameworks, TDTM, and governor limit

    https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.security_locker_service
    Security with Lightning Locker

    https://developer.salesforce.com/docs/component-library/documentation/lwc/events
    Communicate with Events

    What are Events - in DOM and Components
    https://dom.spec.whatwg.org/#events

    https://developer.salesforce.com/docs/component-library/tools/locker-service-console

    What Is the Lightning Component Framework?
    https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/intro_framework.htm

    lightning:recordForm Example
    https://rajvakati.com/2018/05/29/lightningrecordform/

    Introducing Lightning Web Components
    https://developer.salesforce.com/docs/component-library/documentation/lwc

    https://www.biswajeetsamal.com/blog/component-events-in-salesforce-lightning-framework/
    Component Events
    Application Events

    https://help.salesforce.com/articleView?id=flow.htm&type=5
    FLOWS - FLOW Builder


    SLA - Service Level Agreements
    Entitelments









    https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_component_example.htm
    Example -

    travis
    GITHUB

    -- Force.com IDE
    --- PUSH to Scratch Org - Sandbox
    --- Source PUSH ---> Goes to GITHUB Repository


    http://sfdcinpractice.com/index.php/2017/01/23/4-2-introducing-trigger-handler-class/


    http://developer.salesforce.org/#blog/post/2016/06/10/table-driven-trigger-management.html
    https://www.salesforce.org/table-driven-trigger-management-matters/


    Visual Studio Code for Salesforce Development

    Download Visual Studio (Community version)
    https://visualstudio.microsoft.com/downloads/

    https://trailhead.salesforce.com/en/content/learn/modules/git-and-git-hub-basics/work-with-the-git-hub-workflow

    https://trailhead.salesforce.com/en/content/learn/projects/quick-start-salesforce-dx?trail_id=sfdx_get_started


    https://help.salesforce.com/articleView?id=sso_about.htm&type=5

    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.

    LDAP
    https://developer.salesforce.com/forums/?id=906F000000090qPIAQ
    https://help.salesforce.com/articleView?id=identity_provider_examples_3p_adfs.htm
    https://www.google.com/search?q=configuration+of+ldap+for+salesforce&rlz=1C1EJFA_enUS730US731&oq=configuration+of+ldap+for+salesforce&aqs=chrome..69i57.22499j1j7&sourceid=chrome&ie=UTF-8

    AutoRabbit -

    https://trailhead.salesforce.com/en/content/learn/modules/git-and-git-hub-basics/work-with-the-git-hub-workflow

    https://www.google.com/search?rlz=1C1EJFA_enUS730US731&ei=s7_iXL-ZAuLD_QaD0a74Dg&q=salesforce+spring+19+release+date&oq=salesforce+spring+19+release+date&gs_l=psy-ab.3..0i67j0j0i8i30.1327.1327..1586...0.0..0.77.77.1......0....1..gws-wiz.......0i71.dA7nS1wQYmg

    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

    https://developer.salesforce.com/docs/atlas.en-us.draes.meta/draes/draes_group_membership_data_skew.htm

    -----------------------------------------------------------------
    4pm EST - Srinivas Raju - TCS
    Prudential NJ
    Proudutional Insurnace

    Srinivas Punnamaraju
    Principal Consultant at TCS


    -----------------------------------------------------------------

    https://www.google.com/search?q=connected+app+salesforce+oauth&rlz=1C1EJFA_enUS730US731&oq=connected+app+s&aqs=chrome.2.0j69i57j0l4.6448j0j7&sourceid=chrome&ie=UTF-8


    https://help.salesforce.com/articleView?id=connected_app_overview.htm&type=5



    https://www.google.com/search?q=%40future+salesforce&rlz=1C1EJFA_enUS730US731&oq=%40Future&aqs=chrome.1.69i57j0l2j35i39j0l2.2462j0j7&sourceid=chrome&ie=UTF-8




    https://www.salesforcetutorial.com/visualforce-creating-simple-page/



    https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex/async_apex_future_methods


    Attachedment in email - REST






    https://trailhead.salesforce.com/content/learn/modules/sf_cpq


    https://developer.salesforce.com/docs/component-library/bundle/lightning:button/example

    lightning:buttons

    single singon

    Salesforce Integration with outlook
    - standard

    NO automation - "manual scripts"
    Master detial

    Version Control - GITHUB
    Deployemnt tools -
    LIgihting vs Visualforce compoents difference
    Lightning Platform query optimizer FAQ


    Validation Rules
    Triggers
    Assignment Rules
    Auto Response Rules
    Workflow Rules


    Bulk macros
    Lightning Dialer

    ---------------------------------------------------

    SALESFORCE QUESTIONS FOR CANDIDATES

    Questions for SalesforceDeveloper

    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)

    ---------------------------------------------------


    http://results.eci.gov.in/ac/en/constituencywise/ConstituencywiseS01139.htm?ac=139
    https://www.youtube.com/watch?v=acbjEpjy-gw
    https://www.instafinancials.com/director/nara-lokesh/02230945

    https://www.sfdcpanther.com/all-about-apexrest/

    Trigger Framework Architecture....
    https://www.sfdcpanther.com/trigger-architecture-framework-recipe-sfdcpanther/

    Integration...
    https://developer.salesforce.com/blogs/developer-relations/2015/06/integrating-force-com.html

    Post Man Integration...
    https://www.veonconsulting.com/salesforce-rest-api-explained/

    Platform App Builder.

    Guide to Sandboxes
    https://www.slideshare.net/Flosum/the-definitive-guide-to-salesforce-sandbox-flosum



    --------------------------

    SALESFORCE LIGHTNING APP

    1) Create a Developer Edition organization
    2) Register a Namespace Prefix
    3) Define a Custom Salesforce Domain Name (Enable My Domain)

    -----------------------------------------------------------------

    1.Create Components
    2.Style Components
    3.Lightining App Builder
    With AppBuilder (Start--> User Interface --> Lightning App Builder)
    - you can Build
    ---- App Page
    ---- Home Page
    ---- Record Page
    4.Attributes
    5.DataTypes
    6.Collections

    -----------------------------------------------------------------

    Divsion of a page...






    Client-Side Stateful

    -----------------------------------------------------------------
    CSS - Understanding Style Sheets..

    //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';

    .THIS {
    background-color:yellow !important;
    }
    -----------------------------------------------------------------

    Datatypes
    -----------------
    String
    Integer
    Boolean
    List
    Set
    Map
    Array
    sObject
    CustomApex
    Object


    Basic Methods of Component Class
    -----------------------------------
    get (String | Object name)
    set (String keyObject valueProvider)
    find (String | Object name)
    getName()
    isValid()

    VF page = ONE Page
    --------------------------------------------------
    Lighunting = ONEPAGE is SEVERL Components
    -----------------------------------------------------------------

    !v.variableName is for Value Providers
    !c.methodName is for Controller

    We can call Controller.js method from Components
    - We can call helper.js methods from Controller




    -----------------------------------------------------------------

    PreDefined Interfaces

    force:hasRecordId
    force:hasSobjectName
    flexipage:availableForAllPageTypes
    flexipage:availableForRecordHome
    forceCommunity:availableForAllPageTypes
    force:appHostable
    force:lightningQuickAction
    force:lightningQuickActionWithoutHeader
    ltng:allowGuestAccess


    -----------------------------------------------------------------

    // $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..

    --------------------------------
    Reduce Function.
    --------------------------------

    getError()
    pageError
    message


    We write all errors to console log..

    console.

    State === 'INCOMPLETE'
    State === 'ERROR'

    Validation Rules..

    messageWhenBadInput
    messageWhenValueMissing


    --------------------------------------------------------



    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