1. Write an LWC component to fetch Account and its related Contacts and Opportunities and display on UI

You can create an LWC to fetch Account, Contact, and Opportunity data using Apex and display them. Here’s an example:

HTML :

<template>
    <lightning-card title="Account Details" icon-name="standard:account">
        <template if:true={accountData}>
            <p><strong>Account Name: </strong>{accountData.Name}</p>
            <h3>Contacts</h3>
            <ul>
                <template for:each={accountData.Contacts} for:item="contact">
                    <li key={contact.Id}>{contact.Name}</li>
                </template>
            </ul>
            <h3>Opportunities</h3>
            <ul>
                <template for:each={accountData.Opportunities} for:item="opp">
                    <li key={opp.Id}>{opp.Name} - {opp.Amount}</li>
                </template>
            </ul>
        </template>
    </lightning-card>
</template>
JS:
import { LightningElement, wire } from 'lwc';
import getAccountDetails from '@salesforce/apex/AccountController.getAccountDetails';

export default class AccountDetails extends LightningElement {
    accountData;

    @wire(getAccountDetails, { accountId: '001xx000003DGbRAAW' })
    wiredAccountData({ error, data }) {
        if (data) {
            this.accountData = data;
        } else if (error) {
            console.error('Error fetching account data', error);
        }
    }
}
Apex:
public with sharing class AccountController {
    @AuraEnabled(cacheable=true)
    public static Account getAccountDetails(Id accountId) {
        return [SELECT Id, Name, 
                (SELECT Id, Name FROM Contacts),
                (SELECT Id, Name, Amount FROM Opportunities)
                FROM Account WHERE Id = :accountId];
    }
}

2. Can we use setup objects in Screen Flow?

Yes, you can use setup objects in Screen Flow, but you need to have appropriate permissions to access those objects. Setup objects are used for configurations such as User, Profile, PermissionSet, etc.

3. Can we call future method from flow?

No, you cannot directly call a @future method from a Flow. Instead, you can invoke Apex via an invocable method or a queueable class.

4. Can we use Permission Set to control Page Layout assignment?

No, Permission Sets do not control page layout assignments. Page layouts are controlled by Profiles or Record Types.

5. Explain Muting Permission Sets

Muting Permission Sets are used in Permission Set Groups (PSG) to disable or mute certain permissions within the group without removing the entire permission set. It helps in fine-tuning access by muting unnecessary permissions in a PSG.

6. How can we use Owner-based Sharing settings?

Owner-based sharing settings are used to define record access based on the record owner. Sharing rules can be configured to allow records owned by certain users or roles to be shared with other users or groups of users (e.g., roles, public groups).

7. Why are sObject allowed in Queueable but not Future?

Queueable supports more complex types, like sObject and collections, because Queueable jobs can be chained and queued for additional processing. Future methods, however, cannot handle sObject or collections, as they only allow primitive types due to their lightweight nature.

8. Do Out-of-the-box APIs work for Custom Objects?

Yes, Salesforce’s standard REST and SOAP APIs work for custom objects, and you can query or perform operations (CRUD) on custom objects using their API name (e.g., MyCustomObject__c).

9. Display a Component to Only 5 Users on a Record Page (Solution for Dynamic Growth)

You can use a custom Permission Set and assign it to the specific users. Control the visibility of the LWC component based on whether the user has that permission set assigned, using the @salesforce/userPermission or @salesforce/user imports in LWC.

10. Parent to Child, Child to Parent Communication

  • Parent to Child: Use public properties and call child methods using @api decorators.
  • Child to Parent: Use custom events dispatched by the child component to the parent.

11. When is wire method called in the LWC lifecycle?

The wire method is called when the component is initialized and re-called when any reactive dependencies change.

12. SOQL Query to Fetch Opportunity with Max Amount

sql :SELECT Id, Name, Amount FROM Opportunity ORDER BY Amount DESC LIMIT 1

13. How does the system know that data has changed in the backend in wire method?

The system uses reactive variables or parameters in the @wire method. When these reactive dependencies change, the wire service re-executes and refreshes the data.

14. All Configuration Required for Performing Integrations (Inbound and Outbound)

  • Inbound Integration: Configure Salesforce to expose Apex REST/SOAP APIs, set up OAuth, Named Credentials, or authentication.
  • Outbound Integration: Use HTTP Callouts, configure Named Credentials, setup External Services, use Salesforce Connect for external objects, and OAuth/JWT for authentication.

15. Displaying 50k+ Records in LWC without Pagination

You can use the Lightning Data Table with infinite scrolling and load records in chunks using Apex and SOQL queries, but fetching more than 50,000 records in a single query will hit Salesforce limits.

16. Trigger to Update User Object Based on Contact Information

Apex code :trigger ContactToUser on Contact (after insert, after update) {
    List<User> usersToUpdate = new List<User>();
    for (Contact con : Trigger.new) {
        User user = [SELECT Id FROM User WHERE ContactId = :con.Id];
        if (user != null) {
            user.Email = con.Email;
            // update other fields
            usersToUpdate.add(user);
        }
    }
    if (!usersToUpdate.isEmpty()) {
        update usersToUpdate;
    }
}

17. Mixed DML Operation in Flow

If you encounter a mixed DML error in a Flow, you need to separate the DML operations (setup and non-setup objects) by using asynchronous methods like invocable Apex or queueable jobs.

18. How Can a Manager Share Records in a Role Hierarchy with Subordinates?

You can set up sharing settings so that users higher up in the role hierarchy automatically gain access to records owned by their subordinates.

19. What Error Occurs if a User Lacks Access to a Custom Field in Apex?

If a user doesn’t have access to a field and tries to access it, they will get a FIELD_INTEGRITY_EXCEPTION error.

20. How Can We Control Field Level Security in Apex Code?

You can enforce field-level security in Apex by using Schema.sObjectType and checking isAccessible, isCreateable, or isUpdateable on fields before performing operations.

Example:

apex:

if (Schema.sObjectType.Contact.fields.Email.isAccessible()) {
// proceed with your logic
}

2 thoughts on “Top Salesforce Lightning web components (LWC) interview questions and answers”
  1. Solid analysis! Understanding variance is HUGE in tournaments. Seeing platforms like otsobet com focus on data & transparency is a good sign – helps players make informed decisions, especially with those quick deposit options!

  2. I’m always curious about what makes a slot game click with players. Seems like convenience is key now – carrying a casino in your pocket with the jk bose app sounds pretty appealing! Exploring new platforms like this in the Philippines is exciting!

Leave a Reply

Your email address will not be published. Required fields are marked *