TCS Salesforce interview questions
Apex, Flow and LWC scenario questions reported from recent TCS rounds, with practical answers.
TCS hires Salesforce admins and developers in large numbers, and its technical rounds lean on fundamentals plus practical scenarios, especially for LWC and Apex. Below are questions candidates report from recent TCS rounds, with answers in the length you would give them out loud.
These are questions that candidates say they were asked in recent interviews. Companies do not publish official question lists, and every team asks differently, so use this page to practise the style of question, not to memorise answers.
Apex and security
01How do you prevent SOQL injection in Apex?
How do you prevent SOQL injection in Apex?
Use static SOQL with bind variables wherever you can, because bind values are never treated as code. If you must build a query string, bind the values with Database.queryWithBinds(), or escape user input with String.escapeSingleQuotes(), and allow only known field names for sorting or filtering.
Also run the query in user mode (WITH USER_MODE) so the user only gets records and fields they are allowed to see.
02Your code hits a governor limit in production. What do you do?
Your code hits a governor limit in production. What do you do?
First find which limit and where, using the debug log or the error email. Then fix the cause, not the symptom:
- No SOQL or DML inside loops. Query once, store results in a
Map<Id, SObject>, and do one DML on a list. - Filter early so you only process the records that need work.
- Move heavy work to Queueable or Batch Apex, which have higher limits.
- Use the
Limitsclass while testing to see how close you are.
Then test with 200 records in a test class, because that is how a data load or an integration will call your code.
03When do you use Custom Metadata Types and when Custom Settings?
When do you use Custom Metadata Types and when Custom Settings?
Use Custom Metadata Types for configuration that should move between orgs with your code: feature switches, mapping tables, thresholds. Records deploy like metadata and can be read without using SOQL limits.
Use Hierarchy Custom Settings when a value must differ per user or profile, for example a bypass flag for an integration user. List custom settings are an older pattern; most teams now use custom metadata instead.
Flow
04Can you schedule a flow to run every day without Apex?
Can you schedule a flow to run every day without Apex?
Yes. Create a schedule-triggered flow, set the start date, time and frequency (once, daily or weekly), and optionally choose an object and filter so the flow runs once for each matching record. Keep the filter tight so it does not run on records that need no work.
05A flow failed in production. How do you debug it?
A flow failed in production. How do you debug it?
Read the flow error email or the Failed Flow Interviews list, which show the element that failed and the error. Reproduce it in a sandbox with Debug, using the same record values. Check field access of the running user, validation rules and other automation on the same object.
To prevent silent failures, add fault paths on Get, Create, Update and Action elements that log the error to a custom object and show a clear message to the user.
06What is the difference between a before-save and an after-save flow?
What is the difference between a before-save and an after-save flow?
A before-save (fast field update) flow changes fields on the record that is being saved, without extra DML, so it is very fast. An after-save flow runs once the record is saved, so it can create or update other records, send emails, call actions and use the record Id.
Rule of thumb: same-record field updates go in before-save; everything else goes in after-save.
07How can a user enter several child records in one screen flow?
How can a user enter several child records in one screen flow?
Use the Repeater component, which lets the user add as many rows as they need, each with the same fields. Store the rows in a record collection and create them all with one Create Records element at the end, so the flow does one DML for the whole list. For editing existing records, the standard Data Table supports inline editing since Spring '26 for simple field types such as text, number and currency.
LWC scenarios
08Your LWC calls an Apex method that sometimes throws an error. How do you show a useful message?
Your LWC calls an Apex method that sometimes throws an error. How do you show a useful message?
In Apex, catch the expected exceptions and throw an AuraHandledException with a message the user can understand. In the component:
- For an imperative call, use
try/catchwithawait(or.catch()), and show the message in a toast or inline error. - For
@wire, check theerrorproperty; the wire gives you data or an error, it does not throw. - Use a small helper to read the message from
error.body.message, because the error shape differs between Apex, LDS and network errors.
Turn off spinners in a finally block so the component stays usable after an error.
09Build a search box that updates results as the user types. How do you stop it calling Apex on every key press?
Build a search box that updates results as the user types. How do you stop it calling Apex on every key press?
Debounce the input. On each key press, clear the previous timer and start a new one, for example 300 milliseconds. Only call Apex when the timer fires, so a fast typist makes one call, not ten.
handleKeyChange(event) {
clearTimeout(this.timer);
const term = event.target.value;
this.timer = setTimeout(() => { this.searchTerm = term; }, 300);
}Wire the Apex method to searchTerm, mark it cacheable=true, return only the fields you show with a LIMIT, and show "No results found" when the list is empty.
10How would you show a live notification in an LWC when a platform event is published?
How would you show a live notification in an LWC when a platform event is published?
Use the lightning/empApi module. Subscribe to /event/My_Event__e in connectedCallback, show a toast in the callback, and unsubscribe in disconnectedCallback. empApi works on Lightning Experience pages; for other places, or for high volume, consider Change Data Capture or the Pub/Sub API on the server side.
11How do you use a chart library such as Chart.js in LWC?
How do you use a chart library such as Chart.js in LWC?
Upload the library as a static resource, then load it with loadScript from lightning/platformResourceLoader in renderedCallback, with a flag so it loads only once. Draw the chart into a canvas you get with lwc:ref. When the user changes a filter, update the chart's data and call chart.update() instead of drawing a new chart. Lightning Web Security must allow the library, so test it early.
12How do two components that are not parent and child send data to each other?
How do two components that are not parent and child send data to each other?
Use Lightning Message Service. Create a message channel, publish from component A with publish(), and subscribe in component B with subscribe(). The components never reference each other, so either one can be replaced. Unsubscribe in disconnectedCallback, and if messages do not arrive, check that both components use the same channel and the right scope.
13How do you let users select many contacts in a table and update them together?
How do you let users select many contacts in a table and update them together?
Use lightning-datatable with checkbox selection and read getSelectedRows() (or the rowselection event). Send the selected Ids to one Apex method that updates the list with Database.update(records, false). That way one bad record does not stop the rest. Return the success and error count from the SaveResult list and show it to the user, then refresh the table with refreshApex.
14How do you show a countdown timer for a task deadline?
How do you show a countdown timer for a task deadline?
Start a setInterval in connectedCallback that updates a property every second, and clear it in disconnectedCallback so it does not keep running after the user leaves. Calculate the time left from the deadline each tick instead of counting down a number, so it stays correct even if the browser tab sleeps. If the deadline can change, read it from LDS so the timer picks up the new value.
15How do you build a Kanban board where users drag records between columns?
How do you build a Kanban board where users drag records between columns?
Group records into columns by a picklist value, such as Stage. Use the HTML drag events: draggable="true" with ondragstart on each card, and ondragover and ondrop on each column. On drop, update the record's field with updateRecord from lightning/uiRecordApi, move the card in the UI, and move it back with an error toast if the save fails, for example because of a validation rule.
16How do you support several languages in an LWC?
How do you support several languages in an LWC?
Put every user-facing text in Custom Labels, translate them in Translation Workbench, and import them with import label from '@salesforce/label/c.My_Label'. Salesforce returns the label in the user's language. Use lightning-formatted-number and lightning-formatted-date-time so numbers and dates follow the user's locale.