Platform App Builder Flashcards
(261 cards)
A company needs to update 10,000 Opportunity records nightly based on complex logic involving multiple related objects. Can this be achieved declaratively? If not, provide an Apex solution and explain why programmatic customization is required.
Declarative tools like Flow or Process Builder are limited by governor limits (e.g., 2,000 records per batch in Flow). For 10,000 records with complex logic, Apex is required for efficient bulk processing.
public class OpportunityBatch implements Database.Batchable<SObject> {
public Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator('SELECT Id, Amount, Account.Industry FROM Opportunity WHERE LastModifiedDate = TODAY');
}
public void execute(Database.BatchableContext bc, List<Opportunity> scope) {
for (Opportunity opp : scope) {
if (opp.Account.Industry == 'Tech' && opp.Amount > 100000) {
opp.StageName = 'Closed Won';
}
}
update scope;
}
public void finish(Database.BatchableContext bc) {}
}</Opportunity></SObject>
As a CTA, you’re tasked with designing a nightly sync for a client processing 50,000 Opportunities. The logic involves cross-object calculations and external system updates. Propose a solution, justifying why declarative tools are insufficient and how Apex ensures scalability.
A client requires a validation rule that prevents Opportunity closure unless all related Tasks are completed and the Account has a specific custom field value. Can this be done declaratively? If not, provide an Apex trigger.
Declarative validation rules cannot enforce complex cross-object logic involving multiple related records. An Apex trigger is needed.
trigger OpportunityTrigger on Opportunity (before update) {
for (Opportunity opp : Trigger.new) {
if (opp.StageName == ‘Closed Won’) {
List<Task> tasks = [SELECT Id, Status FROM Task WHERE WhatId = :opp.Id AND Status != 'Completed'];
Account acc = [SELECT CustomField\_\_c FROM Account WHERE Id = :opp.AccountId];
if (!tasks.isEmpty() || acc.CustomField\_\_c != 'Approved') {
opp.addError('Cannot close Opportunity until all Tasks are completed and Account is Approved.');
}
}
}
}</Task>
CTA Case Study: A global firm needs Opportunity validation across 10 regions, each with unique rules based on local regulations. Design a solution, explaining why Apex is preferred over validation rules and how you’d ensure maintainability.
A client wants a custom Opportunity page with dynamic fields based on the user’s profile. Can this be achieved declaratively? If not, propose a programmatic solution.
Declarative tools (e.g., Dynamic Forms) have limited support for profile-based field rendering. A Lightning Web Component (LWC) is needed for full control.
public with sharing class OpportunityController {
@AuraEnabled(cacheable=true)
public static List<String> getFieldsForProfile(Id recordId) {
String profileName = [SELECT Name FROM Profile WHERE Id = :UserInfo.getProfileId()].Name;
List<String> fields = new List<String>{'Name', 'Amount'};
if (profileName == 'Sales Manager') {
fields.add('CloseDate');
}
return fields;
}
}</String></String></String>
CTA Case Study: A CTA must design a dynamic UI for a multi-national company with 50 profiles and varying field requirements. Justify using LWC over Dynamic Forms, addressing performance and scalability.
A client needs to sync Salesforce Accounts with an external ERP system in real-time. Is this possible declaratively? If not, provide an Apex callout solution.
Declarative tools (e.g., External Services) are limited for complex, real-time integrations. Apex HTTP callouts are required.
public class ERPSync {
@future(callout=true)
public static void syncAccount(String accountId) {
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(‘https://erp.example.com/api/accounts’);
req.setMethod(‘POST’);
req.setBody(‘{“accountId”: “’ + accountId + ‘”}’);
HttpResponse res = http.send(req);
if (res.getStatusCode() != 200) {
// Log error
}
}
}
A client requires bi-directional ERP sync with 100,000 records daily. Propose a solution, explaining why Apex and Platform Events are needed over declarative tools like Salesforce Connect.
A client wants to send custom email notifications to Opportunity owners when the Amount exceeds $1M, including dynamic content from related records. Can this be done declaratively? If not, provide an Apex solution.
Declarative email alerts lack dynamic content control. Apex is needed for custom email logic.
public class OpportunityNotification {
public static void sendHighValueNotification(List<Opportunity> opps) {
List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
for (Opportunity opp : opps) {
if (opp.Amount > 1000000) {
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setToAddresses(new List<String>{opp.Owner.Email});
email.setSubject('High Value Opportunity: ' + opp.Name);
email.setPlainTextBody('Account: ' + opp.Account.Name + '\nAmount: ' + opp.Amount);
emails.add(email);
}
}
Messaging.sendEmail(emails);
}
}</String></Messaging.SingleEmailMessage></Messaging.SingleEmailMessage></Opportunity>
CTA Case Study: Design a notification system for a client with 1,000 users, requiring localized email templates and audit logging. Justify Apex over Flow-based email alerts.
A client needs a report that aggregates Opportunity data with custom weighted scoring based on multiple fields. Can this be done declaratively? If not, provide an Apex solution.
Declarative reports cannot handle complex weighted scoring. Apex is needed for custom calculations.
public class OpportunityScoring {
public static void calculateScores(List<Opportunity> opps) {
for (Opportunity opp : opps) {
Decimal score = (opp.Amount * 0.5) + (opp.Probability * 0.3) + (opp.CloseDate.daysBetween(Date.today()) * 0.2);
opp.CustomScore\_\_c = score;
}
update opps;
}
}</Opportunity>
CTA Case Study: A CTA must design a scoring system for a client with 10M Opportunities, integrated with Tableau. Explain why Apex and a custom object are preferred over report formulas.
A client needs to dynamically share Opportunity records with a partner portal based on custom criteria. Can this be done declaratively? If not, provide an Apex solution.
Declarative sharing rules cannot handle dynamic, criteria-based portal sharing. Apex is required.
public class OpportunitySharing {
public static void shareWithPartner(List<Opportunity> opps) {
List<OpportunityShare> shares = new List<OpportunityShare>();
for (Opportunity opp : opps) {
if (opp.Partner_Involved\_\_c) {
OpportunityShare share = new OpportunityShare();
share.OpportunityId = opp.Id;
share.UserOrGroupId = [SELECT Id FROM Group WHERE Name = 'Partner Portal'].Id;
share.OpportunityAccessLevel = 'Edit';
shares.add(share);
}
}
insert shares;
}
}</OpportunityShare></OpportunityShare></Opportunity>
CTA Case Study: A global firm needs to share records with 500 partners, with audit trails and revocation logic. Justify Apex over manual sharing rules, addressing security concerns.
A client requires an approval process where approvers are dynamically selected based on Opportunity Amount and Region. Can this be done declaratively? If not, provide an Apex solution.
Declarative approval processes lack dynamic approver logic. Apex is needed.
public class DynamicApproval {
public static void submitForApproval(List<Opportunity> opps) {
for (Opportunity opp : opps) {
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setObjectId(opp.Id);
String approverId = opp.Amount > 500000 ? [SELECT Id FROM User WHERE Region\_\_c = :opp.Region\_\_c AND Role = 'VP'].Id : opp.OwnerId;
req.setNextApproverIds(new List<Id>{approverId});
Approval.process(req);
}
}
}</Id></Opportunity>
CTA Case Study: Design an approval system for a client with 10,000 Opportunities monthly, requiring multi-step approvals and escalations. Explain why Apex is needed over declarative approvals.
A client needs to transform Opportunity data in real-time (e.g., currency conversion) before display. Can this be done declaratively? If not, provide an Apex solution.
Declarative tools cannot handle real-time transformations. Apex and LWC are needed.
public class CurrencyConverter {
@AuraEnabled
public static Decimal convertAmount(Decimal amount, String currencyCode) {
Decimal rate = [SELECT ConversionRate FROM CurrencyType WHERE IsoCode = :currencyCode].ConversionRate;
return amount * rate;
}
}
CTA Case Study: A CTA must design a real-time dashboard for a client with multi-currency operations. Justify using Apex and LWC over formula fields, addressing performance.
A client needs to schedule follow-up Tasks for Opportunities based on a custom algorithm. Can this be done declaratively? If not, provide an Apex solution.
Declarative tools cannot handle complex scheduling algorithms. Apex is required.
public class TaskScheduler {
public static void createFollowUpTasks(List<Opportunity> opps) {
List<Task> tasks = new List<Task>();
for (Opportunity opp : opps) {
Task t = new Task();
t.WhatId = opp.Id;
t.Subject = 'Follow Up: ' + opp.Name;
t.ActivityDate = opp.CloseDate.addDays(opp.Amount > 100000 ? 7 : 14);
t.OwnerId = opp.OwnerId;
tasks.add(t);
}
insert tasks;
}
}</Task></Task></Opportunity>
CTA Case Study: A client needs a scheduling system for 1M Opportunities, with dynamic rules based on industry and region. Propose a solution, justifying Apex over Flow-based scheduling.
A company manually enters contact data from web forms into Salesforce, leading to errors. How can AppExchange address this? Provide an Apex alternative.
AppExchange offers apps like FormAssembly for automated web form integration. These apps map form data to Salesforce objects, reducing errors. Apex can achieve similar automation via a custom web service.
@RestResource(urlMapping=’/WebForm/*’)
global class WebFormService {
@HttpPost
global static String createContact(String firstName, String lastName, String email) {
Contact c = new Contact(FirstName = firstName, LastName = lastName, Email = email);
insert c;
return c.Id;
}
}
CTA Case Study: A global retailer with 1M daily form submissions needs to automate data entry across 50 regions. Propose an AppExchange solution like FormAssembly versus a custom Apex service, justifying scalability, maintenance, and cost considerations.
A sales team struggles with duplicate Leads from marketing campaigns. How can AppExchange help? Provide an Apex alternative.
Apps like DupeBlocker prevent duplicates in real-time across Lead sources. Apex can enforce deduplication via a trigger.
trigger LeadDeduplication on Lead (before insert) {
for (Lead newLead : Trigger.new) {
List<Lead> duplicates = [SELECT Id FROM Lead WHERE Email = :newLead.Email LIMIT 1];
if (!duplicates.isEmpty()) {
newLead.addError('Duplicate Lead detected with email: ' + newLead.Email);
}
}
}</Lead>
CTA Case Study: A financial firm with 10M Leads needs deduplication across Sales Cloud and Pardot. Design a solution using DupeBlocker versus Apex, addressing governor limits and integration complexity.
A marketing team needs to automate personalized campaigns. How can AppExchange assist? Provide an Apex alternative for custom campaign logic.
Apps like Marketo or HubSpot on AppExchange automate campaigns and track engagement. Apex can trigger custom campaign actions.
public class CampaignAutomation {
public static void sendCampaignEmail(List<Lead> leads) {
List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
for (Lead l : leads) {
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setToAddresses(new List<String>{l.Email});
email.setSubject('Personalized Offer for ' + l.FirstName);
email.setPlainTextBody('Dear ' + l.FirstName + ', check our latest offer!');
emails.add(email);
}
Messaging.sendEmail(emails);
}
}</String></Messaging.SingleEmailMessage></Messaging.SingleEmailMessage></Lead>
CTA Case Study: A B2B company with 500,000 Leads requires multi-channel campaign automation. Compare Marketo on AppExchange with a custom Apex/LWC solution, evaluating time-to-market and scalability.
A company lacks native Salesforce accounting features. How can AppExchange address this? Provide an Apex integration example.
Apps like Accounting Seed provide native accounting solutions. Apex can integrate with external accounting systems via callouts.
public class AccountingSync {
@future(callout=true)
public static void syncInvoice(String invoiceId) {
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(‘https://accounting.example.com/api/invoices’);
req.setMethod(‘POST’);
req.setBody(‘{“invoiceId”: “’ + invoiceId + ‘”}’);
HttpResponse res = http.send(req);
if (res.getStatusCode() != 200) {
// Log error
}
}
}
CTA Case Study: A manufacturing firm with $500M revenue needs accounting integration for 100,000 invoices. Propose Accounting Seed versus a custom Apex integration, addressing security and compliance.
A client needs complex dashboards beyond Salesforce Reports. How can AppExchange help? Provide an Apex data aggregation example.
Tableau CRM or other analytics apps on AppExchange offer advanced dashboards. Apex can aggregate data for custom reports.
public class OpportunityAnalytics {
public static Map<String, Decimal> getIndustryTotals() {
Map<String, Decimal> totals = new Map<String, Decimal>();
for (AggregateResult ar : [SELECT Account.Industry, SUM(Amount) total FROM Opportunity GROUP BY Account.Industry]) {
totals.put((String)ar.get(‘Industry’), (Decimal)ar.get(‘total’));
}
return totals;
}
}
CTA Case Study: A healthcare provider with 10M patient records needs predictive analytics. Design a solution using Tableau CRM versus Apex with LWC, considering performance and user adoption.
A support team needs to streamline case management. How can AppExchange assist? Provide an Apex automation example.
Apps like Service Cloud or Zendesk enhance case management. Apex can automate case assignments.
trigger CaseAssignment on Case (before insert) {
Group supportQueue = [SELECT Id FROM Group WHERE Type = ‘Queue’ AND Name = ‘Support Queue’ LIMIT 1];
for (Case c : Trigger.new) {
if (c.Priority == ‘High’) {
c.OwnerId = supportQueue.Id;
}
}
}
CTA Case Study: A telecom with 1M monthly cases needs omni-channel support. Compare Service Cloud on AppExchange with a custom Apex/Flow solution, addressing scalability and maintenance.
A healthcare client needs HIPAA-compliant patient portals. How can AppExchange help? Provide an Apex portal example.
Bolt Solutions on AppExchange offer pre-built healthcare portals. Apex can build custom portals with security controls.
public class PatientPortalController {
@AuraEnabled
public static List<Health_Record__c> getPatientRecords(Id patientId) {
return [SELECT Id, Diagnosis__c FROM Health_Record__c WHERE Patient__c = :patientId WITH SECURITY_ENFORCED];
}
}
CTA Case Study: A hospital network with 500,000 patients needs a HIPAA-compliant portal. Propose a Bolt Solution versus a custom Apex/LWC portal, evaluating compliance and deployment speed.
A team needs project management within Salesforce. How can AppExchange address this? Provide an Apex task scheduler.
Apps like Smartsheet or Monday.com integrate project management. Apex can schedule project tasks.
public class ProjectTaskScheduler {
public static void createTasks(List<Project__c> projects) {
List<Task> tasks = new List<Task>();
for (Project\_\_c p : projects) {
Task t = new Task(WhatId = p.Id, Subject = 'Milestone Review', ActivityDate = p.End_Date\_\_c);
tasks.add(t);
}
insert tasks;
}
}</Task></Task>
CTA Case Study: A consulting firm with 10,000 projects needs integrated project tracking. Compare Smartsheet on AppExchange with a custom Apex solution, addressing user experience and cost.
A sales team needs Outlook integration for email and calendar sync. How can AppExchange help? Provide an Apex email handler.
Salesforce Outlook Integration apps sync emails and calendars. Apex can process inbound emails.
global class EmailHandler implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope env) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
Contact c = [SELECT Id FROM Contact WHERE Email = :email.fromAddress LIMIT 1];
Task t = new Task(WhoId = c.Id, Subject = ‘Email: ‘ + email.subject, Description = email.plainTextBody);
insert t;
result.success = true;
return result;
}
}
CTA Case Study: A global sales team with 5,000 users needs Outlook sync across regions. Propose Salesforce Outlook Integration versus a custom Apex email service, evaluating integration complexity.
A client needs enhanced data security for GDPR compliance. How can AppExchange assist? Provide an Apex security example.
Apps like Data Privacy Manager enforce compliance. Apex can enforce field-level security programmatically.
public class DataSecurity {
public static void restrictAccess(List<Contact> contacts) {
for (Contact c : contacts) {
if (!Schema.sObjectType.Contact.fields.Sensitive_Data\_\_c.isAccessible()) {
c.addError('Access to Sensitive Data is restricted.');
}
}
}
}</Contact>
CTA Case Study: A European bank with 2M customer records needs GDPR-compliant data masking. Design a solution using Data Privacy Manager versus Apex with custom objects, addressing regulatory audits and scalability.
How can an app builder restrict the Marketing team from creating or editing Campaign records while allowing read-only access? Provide an Apex alternative for dynamic access checks.
Use Profiles to set object-level permissions: set Campaign object permissions to “Read” only for the Marketing profile. Apex can enforce dynamic access checks.
public class CampaignAccess {
@AuraEnabled
public static Boolean canEditCampaign(Id campaignId) {
return Schema.sObjectType.Campaign.isUpdateable();
}
}
CTA Case Study: A global firm with 10,000 users needs to restrict Campaign access for 5 regional Marketing teams, each with unique permissions. Design a solution using Profiles and Permission Sets, justifying scalability and maintenance over Apex-based access control.
A client wants to hide the Opportunity Amount field from Sales Reps but allow Managers to edit it. How can this be achieved? Provide an Apex validation example.
Use Field-Level Security (FLS) to set the Amount field to “Read-Only” for the Sales Rep profile and “Edit” for the Manager profile. Apex can validate FLS programmatically.
public class OpportunitySecurity {
public static void enforceFLS(List<Opportunity> opps) {
if (!Schema.sObjectType.Opportunity.fields.Amount.isUpdateable()) {
for (Opportunity opp : opps) {
opp.addError('You lack permission to edit the Amount field.');
}
}
}
}</Opportunity>
CTA Case Study: A financial institution with 50,000 Opportunities needs FLS for 20 sensitive fields across 10 profiles. Propose a solution using FLS and Permission Sets, addressing audit requirements and performance impacts versus Apex enforcement.
How can an app builder ensure Accounts are private except for the owner and their role hierarchy? Provide an Apex sharing example.
Set the Organization-Wide Default (OWD) for Accounts to “Private.” Use role hierarchy to extend access. Apex can create manual sharing records.
public class AccountSharing {
public static void shareWithManager(List<Account> accounts) {
List<AccountShare> shares = new List<AccountShare>();
for (Account acc : accounts) {
AccountShare share = new AccountShare();
share.AccountId = acc.Id;
share.UserOrGroupId = acc.Owner.ManagerId;
share.AccountAccessLevel = 'Edit';
shares.add(share);
}
insert shares;
}
}</AccountShare></AccountShare></Account>
CTA Case Study: A healthcare provider with 1M Accounts needs a private sharing model with exceptions for cross-department collaboration. Design a solution using OWD and Sharing Rules, evaluating Apex sharing for dynamic needs.
A client needs to share Opportunities with Amount > $1M with the Finance team. How can this be done declaratively? Provide an Apex alternative.
Create a criteria-based Sharing Rule on Opportunity to share records where Amount > $1M with the Finance public group. Apex can implement custom sharing logic.
public class OpportunitySharing {
public static void shareHighValueOpps(List<Opportunity> opps) {
List<OpportunityShare> shares = new List<OpportunityShare>();
Id financeGroupId = [SELECT Id FROM Group WHERE Name = 'Finance Team'].Id;
for (Opportunity opp : opps) {
if (opp.Amount > 1000000) {
OpportunityShare share = new OpportunityShare();
share.OpportunityId = opp.Id;
share.UserOrGroupId = financeGroupId;
share.OpportunityAccessLevel = 'Read';
shares.add(share);
}
}
insert shares;
}
}</OpportunityShare></OpportunityShare></Opportunity>
CTA Case Study: A tech firm with 100,000 Opportunities needs dynamic sharing for high-value deals across 20 teams. Compare Sharing Rules with Apex-managed sharing, addressing governor limits and flexibility.