CompanyKPMG
Focus AreaSalesforce Developer
Questions11+
Topics5
KPMG – Salesforce Developer Interview Questions
What's Covered
Topics covered in this interview.
01Flows & Automation2
02Lightning Web Components2
03SOQL & Data1
04Apex & Triggers4
05General & Experience2
All Interview Questions
Every question asked in this interview, listed one by one.
1What is difference between workflow & process builder ?
2Can we send approval through process builder ?
3How to connect apex class with LWC ?
4Have you work on Lighting Web Components ?
5What is relationship between account & contact & also account & opportunity ?
6In Trigger use map - Print Key as AccountId and Values as List of Contacts associated with that Account?
7Write Trigger if account Status field changed to Approved then send email to Owner ?
8What is default size of batch ?
9write test class for opportunity product line ?
10Introduce yourself & Roles and Responsibility.
11What is $A.enqueueaction ?
Preparing for a Salesforce developer interview?
Browse more real company interview experiences and hands-on Apex trigger patterns.
Quick answers to key questions
- Workflow and Process Builder. A workflow rule works on one object and can do four things: update a field, send an email alert, create a task and send an outbound message. Process Builder can use several criteria, create and update related records, call Apex and launch flows. Both are retired, and Flow now does all of this.
- Can we send an approval through Process Builder? Yes, Process Builder had an action to submit a record for approval. In new work, use a flow.
- Connect an Apex class with LWC. Mark the Apex method with
@AuraEnabled, import it in the component withimport getData from '@salesforce/apex/MyClass.getData', and call it with@wireor imperatively. - Relationship between Account and Contact, and Account and Opportunity. Both are one-to-many lookup relationships: one Account can have many Contacts and many Opportunities. A Contact can also be related to more than one Account through Account Contact Relationships.
- Default batch size. 200 records per batch. The maximum you can set is 2,000.
- What is $A.enqueueAction? In Aura components, it queues a server-side action (an Apex controller call) to run. You get the action from the controller, set a callback to handle the response, and then call
$A.enqueueAction(action).
Map of Account Id to its Contacts
Map<Id, List<Contact>> contactsByAccount = new Map<Id, List<Contact>>();
for (Contact c : [SELECT Id, LastName, AccountId FROM Contact WHERE AccountId != null]) {
if (!contactsByAccount.containsKey(c.AccountId)) {
contactsByAccount.put(c.AccountId, new List<Contact>());
}
contactsByAccount.get(c.AccountId).add(c);
}
for (Id accId : contactsByAccount.keySet()) {
System.debug('Key: ' + accId + ' Values: ' + contactsByAccount.get(accId));
}Send an email to the owner when Status becomes Approved
The field name Status__c is assumed. The trigger checks that the value changed to Approved, collects the owners, and sends all emails in one call.
trigger AccountStatusEmail on Account (after update) {
List<Account> changed = new List<Account>();
Set<Id> ownerIds = new Set<Id>();
for (Account a : Trigger.new) {
if (a.Status__c == 'Approved' && a.Status__c != Trigger.oldMap.get(a.Id).Status__c) {
changed.add(a);
ownerIds.add(a.OwnerId);
}
}
if (changed.isEmpty()) return;
Map<Id, User> owners = new Map<Id, User>([SELECT Id, Email FROM User WHERE Id IN :ownerIds]);
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
for (Account a : changed) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(new String[] { owners.get(a.OwnerId).Email });
mail.setSubject('Account approved: ' + a.Name);
mail.setPlainTextBody('The status of ' + a.Name + ' changed to Approved.');
mails.add(mail);
}
Messaging.sendEmail(mails);
}Test class for the Opportunity product line
An Opportunity product line (OpportunityLineItem) needs a product, a price book entry and an Opportunity in the same price book.
@isTest
private class OppLineItemTest {
@isTest
static void createsLineItem() {
Product2 p = new Product2(Name = 'Test Product', IsActive = true);
insert p;
Id stdPb = Test.getStandardPricebookId();
PricebookEntry pbe = new PricebookEntry(
Pricebook2Id = stdPb, Product2Id = p.Id, UnitPrice = 100, IsActive = true);
insert pbe;
Opportunity opp = new Opportunity(Name = 'Test Opp', StageName = 'Prospecting',
CloseDate = Date.today().addDays(30), Pricebook2Id = stdPb);
insert opp;
OpportunityLineItem oli = new OpportunityLineItem(
OpportunityId = opp.Id, PricebookEntryId = pbe.Id, Quantity = 2, UnitPrice = 100);
insert oli;
System.assertEquals(1, [SELECT COUNT() FROM OpportunityLineItem WHERE OpportunityId = :opp.Id]);
}
}