0% found this document useful (0 votes)
3 views11 pages

Interview Questions

Uploaded by

sauravgodbole
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views11 pages

Interview Questions

Uploaded by

sauravgodbole
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Can we create another batachable interface

Can we have another method in Batch class apart from start ,execute and finish
Write a trigger Apex Trigger for a scenario where I have two objects one is Hiring and second
is Candidate . On Candidate we have score ,Hiring lookup and status(picklist with values
Selected, Rejected, Draft, In Progress) field .On Hiring Object we have fields Average score
field which stores average score based on candidate object record when the status is
Selected or Rejected. Please write using best practices

Difference between REST and SOAP api

Limitations of LWC
How can we show same record page for internal user and community user
What is the purpose of lightning element in lwc

locker service in LWC

Why Custom Label is used?


What is difference between AutoLaunched Flow and Record Trigger Flow
I have a scheduled flow which triggers after 30 mins of Account Industry field update , I am
writing test class for the same ; Write test class for same to cover the logic which triggers
after 30 mins
Why salesforce enforces minimum of 75% of code coverage

What is difference between Sales and Service cloud


A Custom object's share object is not available to developer while granting access via Apex
sharinng what will be probable reasons

What is Salesforce security model


public class CandidateTriggerHandler {
public static void updateHiringAverageScore(List<Candidate__c> newCandidates, Map<Id, Candidate__c> oldCandidateM
Set<Id> hiringIds = new Set<Id>();

// Collect Hiring Ids from new and old Candidate records


for (Candidate__c candidate : newCandidates) {
if (candidate.Hiring__c != null) {
hiringIds.add(candidate.Hiring__c);
}
}
if (oldCandidateMap != null) {
for (Candidate__c oldCandidate : oldCandidateMap.values()) {
if (oldCandidate.Hiring__c != null) {
hiringIds.add(oldCandidate.Hiring__c);
}
}
}

if (hiringIds.isEmpty()) {
return;
}

// Use Aggregate SOQL to calculate total score and count in one query
Map<Id, Decimal> hiringAvgScoreMap = new Map<Id, Decimal>();

for (AggregateResult ar : [
SELECT Hiring__c Id, AVG(Score__c) avgScore
FROM Candidate__c
WHERE Hiring__c IN :hiringIds
AND Status__c IN ('Selected', 'Rejected')
GROUP BY Hiring__c
]) {
hiringAvgScoreMap.put((Id) ar.get('Id'), (Decimal) ar.get('avgScore'));
}

// Prepare Hiring updates


List<Hiring__c> hiringUpdates = new List<Hiring__c>();

Cannot Use Third-Party JavaScript Libraries Without Static Resource Upload


Unlike traditional JavaScript apps, LWC does not allow direct imports from CDNs.
External libraries must be uploaded as Static Resources.
🔍 Workaround: Use loadScript() and loadStyle() from lightning/platformResourceLoader.
LightningElement is the base class for all Lightning Web Components (LWC). Every LWC component must extend Lightning
to inherit essential functionalities.
LightningElement is the foundation of every LWC component, providing:
✅ Lifecycle management
✅ Event handling
✅ Secure DOM access
✅ Data binding & LDS support

Locker Service is a security architecture in Salesforce that enforces strict JavaScript security rules to:
✅ Protect against Cross-Site Scripting (XSS) and Cross-Site Request Forgery (CSRF).
✅ Isolate components using Shadow DOM and JavaScript strict mode.
✅ Prevent unauthorized access to Salesforce data and DOM elements.
Benefits of Locker Service
✅ Enhanced Security – Prevents XSS, CSRF, and unauthorized data access.
✅ Better Component Isolation – Components only access their own DOM.
✅ Performance Optimization – Uses JavaScript strict mode for faster execution.
✅ Safe Third-Party Integrations – Ensures that external scripts do not compromise Salesforce data.

We will use Test.setCreatedDate() to simulate a past timestamp and check if the flow gets triggered after 30 minutes
@isTest
public class TestScheduledFlow {
@isTest
static void testScheduledFlowExecution() {
// 1. Create a test Account record
Account testAccount = new Account(Name = 'Test Account', Industry = 'Technology');
insert testAccount;

// 2. Simulate Industry field update


Test.startTest();
testAccount.Industry = 'Finance';
update testAccount;
Test.stopTest();

// 3. Set CreatedDate to 31 minutes ago (force scheduled flow execution)


Test.setCreatedDate(testAccount.Id, System.now().addMinutes(-31));

// 4. Query the Account to verify the update


Account updatedAccount = [SELECT Id, Industry FROM Account WHERE Id = :testAccount.Id];
System.assertEquals('Finance', updatedAccount.Industry, 'Industry update did not trigger the flow');

// 5. (Optional) Check if any dependent fields/processes changed


// Add assertions here based on flow actions (e.g., new records, email logs, field updates, etc.)
}
}
Salesforce enforces 75% code coverage to:
✔ Improve code quality
✔ Prevent unintentional errors in production
✔ Maintain multi-tenant system stability
✔ Promote secure and scalable coding practices

If a Custom Object’s Share Object is Not Available, check:


✅ OWD settings → Must be Private or Public Read Only
✅ Object supports manual sharing
✅ It’s not using implicit or parent-controlled sharing
✅ The Salesforce edition supports Apex sharing
✅ Object name follows Salesforce naming conventions
What is Web To Lead
How to get lead in the salesforce system
How to configure web to lead
How many certification you have
Give the trailhead link
Introduce yourself

I have 2 Profile P1 and P2 for two different employee E1 and E2. A third employee E3 came which is on temporary employee .
access to employee E3 for the access of object which employee E1 have

In an org , we have contacts with Location as picklist field on it having state values
Scenario 1: How to update Annual revenue up to 3rd Hierarchy of Account
Account Main1 = 30000 Annual revenue
Account Master1 = 23000 Annual revenue
AM1.1--> 11000 Annual revenue
AM1.2--> 12000 Annual revenue
Account Master2 = 7000 Annual revenue
AM2.1--> 3000 Annual revenue
AM2.2--> 4000 Annual revenue
How to avoid SOQL 101 error
What is diff between Custom Settings and Custom Metadata
Scenario 2: Accounts with 0 Contacts

Select id,Name
from Account
where id not in (Select AccountId from Contact)

Scenario 3:
Prevent Recursion while updating FirstName on Contact

Trigger ContactTrigger on Contact(after update){

if(Trigger.isAfter && Trigger.isUpdate){


ContactTriggerHelper.UpdateContact(Trigger.new);
}
}

Public Class ContactTriggerHelper{


public static Boolean isTriggerExecuted = false;
public static void UpdateContact(List<Contact> newContacts){

if(isTriggerExecuted){
return;
}

List<Contact> toBeUpdateContacts = new List<Copntact>();


for(Contacts conObject: newContacts){
conObject.FirstName = 'abc ';
toBeUpdateContacts.add(conObject);
}
isTriggerExecuted = true;
if(!toBeUpdateContacts.isEmpty()){
Update toBeUpdateContacts;
}
}

You might also like