salesforce administrator certification Questions

salesforce administrator certification

What is a true statement about the analytics Cloud?
Choose 3 answers
A.It synchronizes with salesforce reporting.
B.It analyzes data from salesforce and external sources.
C.It requires installation of a managed package.
D.It consumes structured, semi-structured, and unstructured data.
E.It is accessible on iOS mobile devices.

What actions can a user perform on an existing Chatter Post?
Choose 2 answers
A.Create a New opportunity
B.Create a new task
C.Add a poll
D.Add a topic

What is the capability of sharing using Manager Groups feature?
Choose 2 answers
A.Users can share records with the Manager Groups through manual sharing.
B.Users can share records up or down their management chain.
C.Users with any Salesforce license type can be included in a Manager Group.
D.Users can add Manager Groups to other Groups for sharing purposes.

How can an administrator make the manager groups feature is available for use?
A.Create an unlisted Chatter group for managers.
B.Add the Manager Groups permission to selected profiles.
C.Enable manager Groups under Organization –Wide Defaults.
D.Enter a request for salesforce to enable Manager Groups.

An Administrator set up matching rules to identify potential duplicates of contact records created by sales users. What type of rule determines what can be done with the duplicate records that are identified by salesforce?
A.Duplicate rule
B.Matching rule
C.Assignment rule
D.Workflow rule
What action types are supported with Lightening Process builder?
Choose 2 answers
A.Create a Record
B.Post a Chatter
C.Outbound Message
D.Create a Filed

What is the capability of report notification?
Choose 2 answers
A.Users can subscribes to report and set the notification criteria.
B.Users can schedule how often notifications are sent for each report.
C.Users can configure automatic notifications for public groups.
D.Uses can schedule report notification for their subordinates.

Manage Salesforce Governor Limits

How to manage Salesforce Governor Limits?

1. Avoid SOQLs,DMLs inside loops, otherwise the query,DML will execute how many time the loop iterates.
2. Provide as many as required conditions while executing the main functionality
3. Use RemoteAction function to make the transaction as asynchronous.
4. Use future annotation to make the transaction asynchronous, but this approach is very costly. We have limited Future calls for transaction.
5. Provide NULL POINTER checks before executing SOQL,DML statements
6. Check whether there is any recursive functionality. If any, avoid those so that we can reduce numbers of SOQLs,DMLs called.
7. Keep required where conditions while executing the SOQL, so that we can get proper result. this can be useful to overcome 50001 query rows.

Examples where we made mistakes while implementing apex code
/**
* Trigger Name: ContactAfterInsert
* Description: When Contact gets successfully inserted, Update the corresponding account. Concatenate contact Id to the account custom field called contactIds__c.
*/
trigger ContactAfterInsert on Contact (after insert){
for(Contact contact: trigger.new){
Account account = [select id from account where id =: contact.accountId];
String existingAccountConts = account.contactIds__c;
// contactIds__c is the custom field in account which contains all the contact ids for that account with separation of colon(:).
account.contactIds__c = existingAccountConts +”:”+ contact.Id;
update account;
}
}
Note: The main thing we have remember is every trigger should be BULKIFIED, here the trigger is not BULKIFIED And we written the SOQL and DML inside for loop.
Suppose we have 160 Contact records in trigger.new(),so obviously the loop iterates 160 times and SOQLs and DMLs will executes 160 times.
as per the Governor limits we have to execute only 100 SOQLs and 150 DMLs records.

How to BULKIFY the above trigger
/**
* Trigger Name: ContactAfterInsert
* Description: When Contact gets successfully inserted, Update the corresponding account. Concatenate contact Id to the account custom field called contactIds__c.
*/
trigger ContactAfterInsert on Contact (after insert){
List<Id> accountIdsList = new List<Id>();
List<Account> updateAccountList = new List<Account>();
for(Contact contact: trigger.new){
accountIdsList.add(contact.accountId);
}
// NULL check before executing the query..
if(!accountIdsList.isEmpty()){
List<Account> accountList = [select id,contactIds__c from account where id IN: accountIdsList];
}
// NULL check before executing the functionality…
if(!accountList.isEmpty()){
for(Account account: accountList){
for(Contact contact: trigger.new){
if(account.Id == contact.accountId){
String existingAccountConts = account.contactIds__c;
// contactIds__c is the custom field in account which contains all the contact ids for that account with separation of colon(:).
account.contactIds__c = existingAccountConts +”:”+ contact.Id;
updateAccountList.add(account);
}
}
}
}
if(!updateAccountList.isEmpty()){
update updateAccountList;
}
}

Example how to resolve SOQL 101 using RemoteAction Annotation.
we have a vf page and class are like this.
// Controller
/***********************************************************
* Class Name: CreateNewOpportunityController
* Description: CreateNewOpportunityController is the controller class to capture the opportunity details
***********************************************************/

public class CreateNewOpportunityController{
// Constructor of class
Public String opptyId{get;set;}
public CreateNewOpportunityController(ApexPages.StandardController Controller){
// Constructor Code….
}
// Method to save the Opportunity record and submit to the approval process.
public PageReference SaveAndSubmit() {
SaveOpportunity();
SubmitOpportunity();
// Once submission is completed page refrence to the details page.
pageReference detailOpportunity = new pageReference(‘/apex/OpportunityDetailPage?id=’+opptyId);
detailOpportunity.setRedirect(true);
return detailOpportunity;
}
SaveOpportunity(){
// Code to save the opportunity
Insert opportunityRecord;
opptyId = opportunityRecord.Id;
}
SubmitOpportunity(){
// Code to Submit the Opportunity
}
}
// Visual Force page
<!——————————————
Page Name: CreateNewOpportunityPage
Description:CreateNewOpportunityController is the controller class to capture the opportunity details
———————————————->

<apex:page standardController=”Opportunity” tabStyle=”FundClaim__c” extensions=”CreateNewOpportunityController” id=”pg”>
<!– create some table to enter opportunity details save and submit the opportunity… –>
<apex:form>
<apex:inputField id=”Name” value=”{!opportunity.Name}”/>
<apex:inputField id=”Stage” value=”{!opportunity.stage}”/>
</apex:form>
<apex:commandButton id=”saveandSubmit” value=”saveandSubmit” action=”{!SaveAndSubmit}”/>
</apex:page>

Note: we have so many triggers on opportunity insert and update, if we click on save and submit so that all the triggers will fire and executed as single transaction and may result to through an error 101SOQL OR Too Many DML Statements.
Just see the below code how to use remote action and make the transaction as asynchronous
// Visual Force page
<!——————————————
Page Name: CreateNewOpportunityPage
Description:CreateNewOpportunityController is the controller class to capture the opportunity details
———————————————->

<apex:page standardController=”Opportunity” tabStyle=”FundClaim__c” extensions=”CreateNewOpportunityController” id=”pg”>
<!– Keep the jQuery lib file in static resources and use that in the page to use jQuery functions (static resource name is jQueryLib )–>
<script src=”{!URLFOR($Resource.jQueryLib)}” type=”text/javascript”></script>
<!– create some table to enter opportunity details save and submit the opportunity… –>
<apex:form>
<apex:inputField id=”Name” value=”{!opportunity.Name}”/>
<apex:inputField id=”Stage” value=”{!opportunity.stage}”/>
</apex:form>
<apex:commandButton id=”saveandSubmit” value=”saveandSubmit” action=”{!SaveAndSubmit}”/>
<!– Script to submit the Opportunity through RemoteAction –>
j$(function(){
if(‘{!opptyId}’!=” && ‘{!opptyId}’!= null){
CreateNewOpportunityController.SubmitOpportunity(‘{!opptyId}’,function(res,eve){
if(eve.status){
var displayMessage = res.split(‘,’);
if(displayMessage[0]==’Success’){
window.top.location.href= ‘/apex/OpportunityDetailPage?id=’+opptyId;
}
}
}
}
}
</apex:page>

// Controller
/***********************************************************
* Class Name: CreateNewOpportunityController
* Description: CreateNewOpportunityController is the controller class to capture the opportunity details
***********************************************************/

public class CreateNewOpportunityController{
// Constructor of class
Public String opptyId{get;set;}
public CreateNewOpportunityController(ApexPages.StandardController Controller){
// Constructor Code
}
// Method to save the Opportunity record and submit to the approval process.
public PageReference SaveAndSubmit() {
SaveOpportunity();
}
SaveOpportunity(){
// Code to save the opportunity
Insert opportunityRecord;
opptyId = opportunityRecord.Id;
}
@remoteAction
public static string SubmitOpportunity(String opptyId){
String returnString;
Opportunity opportunity = [select id,stage from Opportunity where id =: opptyId];
// Code to Submit the Opportunity
if(any errors while submitting){
returnString = ‘Fail,’+ ‘Error message’;
}
else{
returnString = ‘Success,’+’Success message’;
}
return returnString;
}
}

–> The above code will work as two transactions one is for save and one for submit, So the Governor limits will applicable for save and submit differently.

——————————————————————————————————–
How Future Annotation is used to make the transaction as asynchronous
let say we have same above scenario, save and submit opportunity

/ Controller
/***********************************************************
* Class Name: CreateNewOpportunityController
* Description: CreateNewOpportunityController is the controller class to capture the opportunity details
***********************************************************/

public class CreateNewOpportunityController{
// Constructor of class
Public String opptyId{get;set;}
public CreateNewOpportunityController(ApexPages.StandardController Controller){
// Constructor Code….
}
// Method to save the Opportunity record and submit to the approval process.
public PageReference SaveAndSubmit() {
SaveOpportunity();
SubmitOpportunity(opptyId);
// Once submission is completed page refrence to the details page.
pageReference detailOpportunity = new pageReference(‘/apex/OpportunityDetailPage?id=’+opptyId);
detailOpportunity.setRedirect(true);
return detailOpportunity;
}
SaveOpportunity(){
// Code to save the opportunity
Insert opportunityRecord;
opptyId = opportunityRecord.Id;
}
SubmitOpportunity(opptyId){
Opportunity opportunity = [select id,stage from Opportunity where id =: opptyId];
// Code to Submit the Opportunity
}
}
// Visual Force page
<!——————————————
Page Name: CreateNewOpportunityPage
Description:CreateNewOpportunityController is the controller class to capture the opportunity details
———————————————->

<apex:page standardController=”Opportunity” tabStyle=”FundClaim__c” extensions=”CreateNewOpportunityController” id=”pg”>
<!– create some table to enter opportunity details save and submit the opportunity… –>
<apex:form>
<apex:inputField id=”Name” value=”{!opportunity.Name}”/>
<apex:inputField id=”Stage” value=”{!opportunity.stage}”/>
</apex:form>
<apex:commandButton id=”saveandSubmit” value=”saveandSubmit” action=”{!SaveAndSubmit}”/>
</apex:page>

Problems of this approach:
–> This approach is very costly, because we have limited number of future call per transaction and for the instance.
–> This call may not done immediately, it depends on how many batch,scheduler and future call are in queue.
Some times future call takes 2 or 3 days also to run the functionality. So is there any independent functionality and check there is no business impact on this, we can use this method.
Ex: If we want to share records to some optional users in the organization and that should not be done immediately. In that case we go for this approach to keep the sharing functionality oin future call.

Salesforce Governor Limits

Salesforce Governor Limits

Since Salesforce runs on multi-tenancy environment and in order to have same performance to the database,it has imposed some run time limits called governor limits.

There are many types of Salesforce Governor limits like Pre transaction limits, Force.com platfform apex limits, static apex limits and many other limits.

Below are the Pre transaction limits

Description Synchronous Limit Asynchronous Limit
Total number of SOQL queries issued (This limit doesn’t apply to custom metadata types. In a single Apex transaction, custom metadata records can have unlimited SOQL queries.) 100 200
Total number of records retrieved by SOQL queries 50,000
Total number of records retrieved by Database.getQueryLocator 10,000
Total number of SOSL queries issued 20
Total number of records retrieved by a single SOSL query 2,000
Total number of DML statements issued 150
Total number of records processed as a result of DML statements, Approval.process, ordatabase.emptyRecycleBin 10,000
Total stack depth for any Apex invocation that recursively fires triggers due to insert, update, or delete statements 16
Total number of callouts (HTTP requests or Web services calls) in a transaction 100
Maximum timeout for all callouts (HTTP requests or Web services calls) in a transaction 120 seconds
Maximum number of methods with the future annotation allowed per Apex invocation 50
Maximum number of Apex jobs added to the queue with System.enqueueJob 50
Total number of sendEmail methods allowed 10
Total heap size 6 MB 12 MB
Maximum CPU time on the Salesforce servers 10,000 milliseconds 60,000 milliseconds
Maximum execution time for each Apex transaction 10 minutes
Maximum number of unique namespaces referenced 10
Maximum number of push notification method calls allowed per Apex transaction 10
Maximum number of push notifications that can be sent in each push notification method call 2,000

 To know the more Salesforce Governor Limits Salesforce Apex Limits

salesforce developer certification questions

salesforce developer certification Preparation – 3

1. What action types are supported with Lightning Process Builder?
Choose 3 answers
A. Create a Filed
B. Outbound Message
C. Create a Record
D. Post to Chatter

2. How can an administrator make the manager Groups feature available for use?
A. Enable Manager Groups under Organization –Wide Defaults.
B. Add Manager Group permission to selected profiles.
C. Enter a request for Salesforce to enable Manger Groups.
D. Create an unlisted Chatter group for managers.

3. What is a true statement about the Analytic Cloud?
Choose 3 answers
A. It requires installation of a managed package.
B. It analyzes data from Salesforce and external sources.
C. It synchronizes with Salesforce reporting.
D. It is accessible on IOS mobile devices.
E. It consumes structured, semi – structured, and unstructured data.

4. Want is the capability of report notification?
Choose 2 answers
A. Users can subscribe to reports and set the notification criteria.
B. Users can schedule report notifications for their subordinates.
C. Users can configure automatic report notifications for public groups.
D. Users can schedule how often notifications are sent for each report.

5. What is the capability of sharing using the manager Groups feature?
Choose 2 answers
A. Users can add Manager Groups to other Groups for sharing purpose.
B. Users can share records with the manager Group through manual sharing.
C. Users with any Salesforce license type can be included in a Manager Group.
D. Users can share the records up or down their Management chain.

6. How can Lightning process builder be used to automate business process?
Choose 2 answers
A. Define steps and approvers in an approval process.
B. Send an email when a case has been open for 30 Days.
C. Create an order renewal when an opportunity is won.
D. Prevent users from deleting accounts with open opportunities.

job schedule in Salesforce by using Apex

Job schedule by using Apex programming:

Job schedule means, we can schedule a job/class for every hour/day/week/month/year by Apex programming in Salesforce.

Schedule class: Scheduler is a class to run the peace code (class) at specific time, first we have to implement the schedulable interface and then we have to schedule that scheduler class. We have to two ways to schedule a class.

1. Job Schedule from UI: Schedule a class through standard Salesforce user interface.
Create Apex class that implements Salesforce provided interface schedulable.
global class TestSchedulerClass implements Schedulable{
global void execute(SchedulableContext sc){
// Create Account Object with the name test.
Account account = new Account;
account.name = ‘Test account created from scheduler’;
Insert account;
}
}
Schedule this class with standard interface
Go to setup->develop->Apex Classes->click on Schedule a class button and provide the data as like shown in the below screen shot.

Job Schedule

This scheduler runs every day at 12AM and we can check the status in scheduled jobs under monitor section.

Note: The above standard interface is not works for some scenarios like, if we want to schedule the same class every 15mins or monthly, etc… So At this scenario we can go for system. Schedule method

2. Schedule a class through the System.Schedule method.
We run following Apex script in anonymous block to schedule the above class to run every 15mins using CRON expression.

System.schedule(‘ TestSchedulerClass Job1’, ‘0 0 * * * ?’, new TestSchedulerClass ());
System.schedule(‘TestSchedulerClass Job 2′, ‘0 15 * * * ?’, new TestSchedulerClass ());
System.schedule(‘TestSchedulerClass Job 3’, ‘0 30 * * * ?’, new TestSchedulerClass ());
System.schedule(‘TestSchedulerClass Job 4’, ‘0 45 * * * ?’, new TestSchedulerClass ());

How to export data in .csv by using apex code?

Export data by using Apex Code

In salesforce, we cannot export data from standard or custom reports every time and we cannot export data through data loader every time. In this case we can write the apex script and run in anonymous block to export data in .csv file.

Scenario: Export data from parent object (Company) which doesn’t have any child (Company members).

Execute below code in developer console.

 

List<company__c> extractcompanyMemList = new List<company__c>();
List<company__c> companytList = [select id,name,(select id from companymemebers__r) from company__c];
for(RequestClaimJunction__c company: companytList){
List<companymemeber__c> companyMemList = company.companymemebers__r;
if(companyMemList.size() == 0){
extractcompanyMemList.add(company);
}
}
String generatedCSVFile =”;
List<String> queryFields = new List<String>{‘Id’,’Partner Account’,’Status’};
String fileRow = ”;
for(company__c company: extractcompanyMemList){
fileRow = ”;
fileRow = fileRow +’,’+ company.Id;
fileRow = fileRow +’,’+ company.Name;
fileRow = fileRow.replaceFirst(‘,’,”);
generatedCSVFile = generatedCSVFile + fileRow + ‘\n’;
}
Messaging.EmailFileAttachment csvAttachment = new Messaging.EmailFileAttachment();
Blob csvBlob = blob.valueOf(generatedCSVFile);
String csvName = ‘company details which doesn’t have members.csv’;
csvAttachment.setFileName(csvName);
csvAttachment.setBody(csvBlob);
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[]{‘Your Email Id’};
String subject = ‘company details which doesn’t have members CSV’;
email.setSubject(subject);
email.setToAddresses(toAddresses);
email.setPlainTextBody(‘company details which doesn’t have members CSV’);
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttachment});
Messaging.SendEmailResult[] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[]{email});