0% found this document useful (0 votes)
9 views

Salesfo

The document outlines various tasks and methods related to Salesforce Apex programming, including creating and managing Account, Contact, and Opportunity records, as well as implementing triggers and batch processes. It specifies requirements for data manipulation, such as updating fields based on conditions, sending emails, and generating maps from lists. Additionally, it includes examples of how to handle employee records and case types, along with SOQL queries for data retrieval.

Uploaded by

paresh bhandari
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)
9 views

Salesfo

The document outlines various tasks and methods related to Salesforce Apex programming, including creating and managing Account, Contact, and Opportunity records, as well as implementing triggers and batch processes. It specifies requirements for data manipulation, such as updating fields based on conditions, sending emails, and generating maps from lists. Additionally, it includes examples of how to handle employee records and case types, along with SOQL queries for data retrieval.

Uploaded by

paresh bhandari
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/ 28

-=

Create 10 Account Object Records with their Billing Address.


Create an Account with 5 employees (NumberOfEmployees = 5), and then create the same number of
associated Contacts as the Account's NumberOfEmployees.
Create an Opportunity record where the Close Date is set to 10 days after the Created Date.
Update the Opportunity stage to 'Close Lost' for records where the stage is 'Negotiation/Review' and the
created date is more than 5 days ago.
Create PriceBookEntry with Record Type.
Write an Apex method that calculates the total Quantity of all OpportunityLineItem records associated
with an Opportunity. Store the result in a custom field Total_Product_Quantity__c on the Opportunity
object.
Write an Apex method that clones an Opportunity record, including all associated OpportunityLineItem
records. The cloned Opportunity should have a modified CloseDate set to 30 days after the original
CloseDate.
Create an attachment having File name 'Dummy' with type 'pdf' and link it to a account record in
salesforce using apex.
Create an File having File name 'Dummy' with type 'pdf' using ContentDocument version and link it to a
account record in salesforce using apex.

Write an Apex class that sends a single email to a specified contact. The email should contain the subject
"Greetings from Salesforce" and the body "Welcome to Salesforce Apex Email Practice."

Write an Apex class that retrieves one document from Salesforce (e.g., an Attachment or ContentVersion
record) and sends it as an attachment in an email. The email should be sent to a specified contact with
the subject "Document Attached."

Write an Apex class that sends an email using a predefined email template. The template should be
based on the Contact object, and the method should send the email to a specific contact. Ensure that the
method uses the template ID and merges the fields from the Contact record.

Map Related Questions

Given a string employeeId a map of string to string employeeIdToEmail that contains employee IDs as
keys and the employee's email address as the value, return the email associated with the passed
employeeId. If the employee ID is not found, return '[email protected]'.

For example, if the map employeeIdToEmail contains the following keys and values:

'6752' -> '[email protected]'


'19228' -> '[email protected]'
'4823' -> '[email protected]'
The method call employeeEmail(employeeIdToEmail, '4823') should return
'[email protected]'.
Implement the method phonebook that takes as input a list of Contacts, and returns a Map containing the
full names as keys, and the contact's phone number as values. Do not include contacts without a phone
number into the phonebook.

For example, given the following contacts:

c1
Name: 'Bryan McCartney'
Phone: '2143452398'
c2
Name: 'Janice Gonzalez'
Phone: '6923849837'
The method call phonebook(new List {c1, c2}) should return a map containing the following key/value
pairs:

'Bryan McCartney' -> '2143452398'


'Janice Gonzalez' -> '6923849837'

Implement the method phoneToAccount that takes as input a list of Accounts, and returns a Map
containing the phone number as a key and the Account record as the value. Do not include accounts
without a phone number.

For example, given the following accounts:

a1
Name: 'Acme Enterprises'
Phone: '2143452398'
a2
Name: 'Universal Containers'
Phone: '6923849837'
The method call phoneToAccount(new List {a1, a2}) should return a map containing the following
key/value pairs:

'2143452398' -> a1
'6923849837' -> a2
The method industrySummary takes as input a list of accounts with Industry and AnnualRevenue fields
populated. The method should sum up annual revenue by each industry and return a Map with each
industry as a key, and sum of annual revenue for that industry as the value.

For example, given the following accounts:

a1
Name: 'Acme Enterprises'
Industry: 'Banking'
AnnualRevenue: 550,000
a2
Name: 'Universal Containers'
Industry: 'Retail'
AnnualRevenue: 200,000
a3
Name: 'SForce Capital'
Industry: 'Banking'
AnnualRevenue: 450,000
The method call industrySummary(new List {a1, a2, a3}) should return a map containing the following
key/value pairs:

'Retail' -> 200,000


'Banking' -> 1,000,000

The method casesByType takes as input a list of cases and returns a Map> with case types (Type field
on Case) as the keys, and a list of cases of that type as values. This map should not include cases with
no Type specified.

For example, given the following cases:

c1
Subject: 'Power does not come on'
Type: 'Electrical'
c2
Subject: 'Several switches not responding'
Type: 'Electrical'
c3
Subject: 'Lever jammed - cannot run machine'
Type: 'Structural'
The method call casesByType(new List {c1, c2, c3}) should return a map containing the following
key/value pairs:

'Electrical' -> { c1, c2 }


'Structural' -> { c3 }
Naman Paresh Nadeem Gaurav

Completed Completed Completed Completed

Completed Completed Completed Completed


Completed Completed Completed Completed

Completed Completed Completed Completed


Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed


Completed Completed Completed Completed

Completed Completed Completed Completed


Completed Completed Completed Completed

Completed Completed Completed Completed


Test Class Paresh Nadeem

Completed Completed

Completed Completed
Completed Completed

Completed Completed
Completed Completed

Completed Completed

Completed Inprogress

Completed Completed

Completed Completed

Completed Completed

Completed Completed

Completed Completed

Sumit

Completed Completed Completed


Completed Completed Completed

Completed Completed Inprogress


Completed Completed NotStarted

Completed Completed NotStarted


Gaurav

Completed

Completed
Completed

Completed
Completed

Completed

Completed

Completed

Completed

Completed

Completed

Completed

Shubham D

Completed
Completed

Completed
Completed

Completed
Questions
Upon Account Creation if Industry is not null and having value as 'Media' then
populate Rating as Hot.
Upon Opportunity Creation if Amount is not null and is greater than 10000 then
populate 'Hot Opportunity' in description field.
When an Account inserts and CopyBillingToshipping (new field) checkbox is
checked then automatically copy account Billing address into account shipping
address.
Upon Creation of Position (Custom Object) if it is a new position and open
date(new field), Min Pay(new field), & Max Pay(new field), are not populated
then populated them with below values.
(a) Open Date = Today's date
(b) Min Pay = 10000
(c) Max Pay = 15000

Create related Contact when an account is created.


Create a related Opportunity when an Account is created and Account Active =
'Yes'.
" When a case is created on any Account, put the latest case number on the
Account in the 'Latest Case Number' (Text) field."
Account record should have a field named 'Recent Opportunity Amount'. It
should contain the latest opportunity amount created on account.
On Account Create two checkbox fields labled as Contact and Opportunity. Now
when a new Account record is created and if a particular Contact or Opportunity
checkbox is checked then create that related record. Also Opportunity records
should be created only if the Account record Active picklist is populated with a
'Yes'
Write a trigger on Account when Account Active field is updated from ‘Yes’ to
‘No’ then check all opportunities associated with the account. Update all
Opportunities Stage to close lost if stage not equal to close won.
If an opportunity is closed then, no one should be able to delete it except the
user having a System Administrator profile.
Upon contact creation an email should be sent to email populated on Contact
with specified template.

Prevent account record from being edited if the record is created 7 days back.
Create two record types named as “Partner Case” and “Customer Case” on
Case Object. On creation of Case, as per the record type populate the total
number of Partner Case or Customer Case on Account object. Create Custom
Fields on Account to have total numbers.
When any Opportunity is created with amount populated or Opportunity Amount
is updated then populate total Amount on Account Level for all related
opportunities in Annual Revenue Field. If opportunity is deleted or undeleted
then update Amount on Account as well.
When the Employee record is inserted, updated, deleted and undeleted then
update ‘Present Employee Count’ on related Account.

Set OWD as Private for Account. Once an Account record is created, it should
be automatically shared with any one user who belongs to Standard User profile.
Naman Paresh Nadeem Gaurav

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed


Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed


Sumit Test Class Gaurav

Completed Completed

Completed Completed

Completed Completed

Completed Completed

Completed Completed

Completed Completed

Completed Completed

Completed Completed

Completed Completed

Completed Completed

Completed Inprogress

Completed NotStarted

Completed NotStarted

Completed NotStarted
Completed NotStarted

Completed NotStarted

Completed NotStarted
Paresh Nadeem

Completed NotStarted

Completed NotStarted

Completed NotStarted

Completed NotStarted

Completed NotStarted

Completed NotStarted

Completed NotStarted

Completed NotStarted

Completed NotStarted

Completed NotStarted

Completed NotStarted

Inprogress NotStarted

NotStarted NotStarted

NotStarted NotStarted
NotStarted NotStarted

NotStarted NotStarted

Inprogress NotStarted
Question

Fetch the child record from parent record (Contact is child and Account is
Parent) – Standard Objects

Fetch the child record from parent record (Student__c is child and Teacher__c
is Parent) – Custom Objects

Fetch the Parent record from child record (Contact is child and account is Parent ) - Standard obj

Fetch the Parent record from Child Record (Student__c is child and Teacher__c
is Parent) – Custom Object

Fetch the first 10 Accounts where the Industry is 'Technology'.

Fetch all Accounts where the Industry is not 'Healthcare'.

Fetch the Latest Account Record

Fetch the Account record which is group by Name and count the record

Fetch the Lead record where name end with ‘abc’

Fetch all Accounts, ordered by Name in ascending order and Industry not null.

Fetch all Accounts where the Industry is either 'Technology' or 'Finance'. (Without using OR opera

Fetch the Lead Record that are associate with each LeadSource that generated
more than 10 times

Fetch the records from the recycle bin using soql ?

fetch all fields in SOQL Query?


fetch all standard fields in SOQL Query?

fetch all custom fields in SOQL Query?

Fetch the Account that has no contact record

Create a multi-select picklist custom field named 'Skills' on the Account object, with the following
values:
a. Apex
b. LWC
c. Aura
d. VF Page
e. JavaScript
f. Rest API

1. Fetch all Accounts that must have Skills 'Apex', 'LWC', and 'Rest API'
2. Fetch all Accounts that must not have Skills 'VF Page', 'JavaScript', and 'Aura'
3. Fetch all Accounts that either have Skills 'LWC' and 'JavaScript' or 'Apex' and 'Rest API'
(without OR)
4. Fetch all Accounts that neither have Skills 'LWC' and 'JavaScript' nor 'Apex' and 'Rest API'
(without OR)
Sumit Naman Paresh Nadeem

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed


Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed

Completed Completed Completed Completed


Gaurav

Completed

Completed

Completed

Completed

Completed

Completed

Completed

Completed

Completed

Completed

Completed

Completed

Completed

Completed
Completed

Completed

Completed

Completed
Create a batch class to update all account records ,if industry = agriculture then update
industry ='manufacturing' else if industry = 'manufacturing' then update industry = 'agriculture'
and then count number of records which are updated and which are failed and send the record
count via email to current user.
Create schedule class and schedule above batch daily 12 PM
Create a new account with new user with future method and in future method create a
queuable class in which Update the Account.Status__c field to 'Active' for all accounts that
were created more than a year ago.
Paresh Nadeem Gaurav

Completed Completed Completed


Completed Completed Completed

Completed Completed Completed

You might also like