Infosys – Salesforce Developer Interview Questions
What's Covered
Topics covered in this interview.
All Interview Questions
Every question asked in this interview, listed one by one.
Preparing for a Salesforce developer interview?
Browse more real company interview experiences and hands-on Apex trigger patterns.
Quick answers to key questions
- LWC lifecycle.
constructor,connectedCallback(component inserted),render,renderedCallback(after rendering) anddisconnectedCallback(removed).errorCallbackcatches errors from child components. - PubSub model in LWC. It lets components that are not in a parent and child relationship share events. The older
pubsubmodule is limited to one page, and Salesforce recommends Lightning Message Service, which also works across the DOM, Aura and Visualforce. - Role and profile. A profile controls what a user can do (object, field and system permissions). A role controls which records the user can see in the hierarchy.
- List and hierarchical custom settings. A list custom setting stores a table of named records that you read by name, the same for every user. A hierarchical custom setting can hold different values for the whole org, a profile or a single user, and returns the most specific value for the running user. It is often used for bypass switches.
- How many roll-up summary fields can one object have? 25 by default.
- What is a wire adapter? A wire adapter is a function that provides data to a property or function marked with
@wire, for examplegetRecordorgetObjectInfo. Use it when you want reactive, read-only data that refreshes when its parameters change. - Query to get all Opportunities of an Account.
SELECT Id, Name, StageName FROM Opportunity WHERE AccountId = :accountId, or as a subquery from the Account:SELECT Id, (SELECT Id, Name FROM Opportunities) FROM Account.
Send data from child to parent in LWC
The child dispatches a custom event and the parent listens for it.
// child.js
handleClick() {
this.dispatchEvent(new CustomEvent('senddata', {
detail: { name: 'Acme' }
}));
}
// parent.html
<c-child onsenddata={handleData}></c-child>
// parent.js
handleData(event) {
this.childName = event.detail.name;
}Show Name, Phone and Website of an Account in LWC
There are several ways: lightning-record-view-form (no JavaScript), lightning-record-form, the getRecord wire adapter, an Apex method with @wire, or an imperative Apex call. Here is the getRecord version:
import { LightningElement, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
const FIELDS = ['Account.Name', 'Account.Phone', 'Account.Website'];
export default class AccountInfo extends LightningElement {
@api recordId;
@wire(getRecord, { recordId: '$recordId', fields: FIELDS })
account;
get name() { return this.account.data ? this.account.data.fields.Name.value : ''; }
get phone() { return this.account.data ? this.account.data.fields.Phone.value : ''; }
get website() { return this.account.data ? this.account.data.fields.Website.value : ''; }
}Trigger: count Cars and Bikes on the Vehicle record
Write one trigger on Car and one on Bike that run after insert, update, delete and undelete. Each trigger collects the Vehicle Ids from the changed records, counts the related Cars and Bikes with an aggregate query grouped by Vehicle, and updates No_of_Cars, No_of_bikes and No_of_Vehicle (their sum) on the Vehicle records in one update. Use the Vehicle Id from Trigger.old for delete. If the relationship is master-detail, roll-up summary fields can do the same without code.