Salesforce Apex Interview Questions & Answers #salesforce #apex #interview
Summary
TLDRIn this fifth installment of the Apex interview preparation series, the host, Jen, addresses frequently asked questions about Salesforce's Apex programming. Topics include the limitations of future methods, such as the inability to pass SObjects and the restriction on chaining or scheduling them. The video also covers batch Apex, explaining its methods, the difference between using Database.QueryLocator and Iterable, and the importance of stateful and stateless batch jobs. Additionally, Jen discusses error handling and the key limits of batch Apex, providing practical insights for interview preparation and real-world application.
Takeaways
- π The video is part of an interview preparation series focusing on Apex in Salesforce, addressing frequently asked questions from the audience.
- π The first discussed topic is the limitation of the `@future` method not supporting the SObject data type due to the potential for data changes during asynchronous execution.
- π A recommended workaround for the `@future` method's limitation is to pass the ID of the SObject and query the latest record within the method itself.
- β It is not advised to pass SObjects through serialization and deserialization in `@future` methods, though it's mentioned as an alternative for scenarios where the SObject is guaranteed not to change.
- π« The `@future` method cannot be called from another `@future` method or from a batch job due to Salesforce's restrictions on asynchronous operations.
- π’ The limit on the number of `@future` method invocations per transaction is 50, which is a key consideration to avoid hitting execution limits.
- π Scheduled Apex does not support callouts, but there are workarounds involving the use of `@future` methods with `callout=true` or batch Apex.
- π¬ Batch Apex is introduced as a method for processing large sets of records with limitations on the number of jobs that can be scheduled and executed.
- π Batch Apex has three key methods: `start`, `execute`, and `finish`, each serving a specific purpose in the batch process.
- π Batch Apex can be stateless by default, but the `Database.Stateful` interface can be implemented to maintain state across multiple transactions.
- π¨ Error handling in Batch Apex can be achieved by implementing the `Database.ErrorPlatformEvent` interface, which is triggered automatically on errors or exceptions.
Q & A
Why doesn't the future method support the SObject data type?
-The future method in Salesforce does not support SObject data types because it is not guaranteed that the SObject passed as an argument will remain unchanged by the time the future method executes. To handle this, Salesforce recommends passing the ID and querying the latest SObject record within the future method.
What is an alternative way to pass SObject data to a future method if you are certain it won't change?
-As an alternative, you can pass the SObject by serializing it to a string and then deserializing it within the future method. However, this is not the recommended approach due to potential issues with data integrity and the complexity it introduces.
Can you call one future method from another future method?
-No, Salesforce does not allow chaining of future methods. Each future method must be invoked independently, and this is one of the limitations of using future methods.
Is it possible to call a future method from a batch job?
-No, Salesforce does not allow calling a future method from a batch job due to the risk of hitting the governor limits on the number of future method invocations per transaction.
What is the limit on the number of future method invocations per transaction?
-The limit on the number of future method invocations per transaction is 50. This is to prevent hitting the governor limits that could cause the transaction to fail.
Can you schedule a future method to execute periodically?
-No, future methods are designed for one-time asynchronous execution and cannot be scheduled to run periodically.
What are some key limitations of future methods that a developer should be aware of?
-Key limitations of future methods include: they are not suitable for processing large sets of records, they do not support chaining, they only support primitive data types, and they do not allow for programmatic tracing of their execution status.
What is the maximum number of jobs that can be scheduled at a given time in Salesforce?
-In Salesforce, you can schedule a maximum of 100 jobs at a given time.
How can you count the number of scheduled jobs in Salesforce?
-To count the number of scheduled jobs in Salesforce, you can query the `CronTrigger` object where the `JobType` is equal to 'S', which represents Scheduled Apex.
Can you write a sample Batch Apex class?
-A sample Batch Apex class should implement the `Database.Batchable<SObject>` interface and include the `start`, `execute`, and `finish` methods. The `start` method is responsible for collecting records, the `execute` method performs operations on these records, and the `finish` method is used for any post-processing tasks such as sending confirmation emails or submitting additional jobs.
What is the significance of the three methods in Batch Apex: start, execute, and finish?
-The `start` method is called at the beginning of the Apex job to collect records for processing. The `execute` method performs the actual operations on the collected records. The `finish` method is called after all batches have been processed and can be used for tasks like sending confirmation emails or submitting additional jobs.
What are the two return types for the start method in Batch Apex and when should each be used?
-The two return types for the start method in Batch Apex are `Database.QueryLocator` and `Iterable<SObject>`. The `Database.QueryLocator` is used when you need to query a large number of records directly from the database, up to 50 million. The `Iterable<SObject>` is used when you need custom control over how records are iterated and processed, such as when working with a custom collection of records.
What is the difference between using the Database.QueryLocator and the Iterable interface in Batch Apex?
-The `Database.QueryLocator` allows for querying up to 50 million records directly from the database, bypassing the standard SQL query limits. The `Iterable<SObject>` interface provides custom control over iterating and processing records, which is useful when working with custom collections or CSV files, but it is subject to the standard governor limits for SOQL queries.
What is the purpose of the Database.StateMachine interface in Batch Apex?
-The `Database.StateMachine` interface in Batch Apex is used to maintain state across multiple transactions within a batch job. This is useful when you need to share information or counts across batches, such as tracking the number of successful or failed records processed.
Can callouts be made within a Batch Apex job?
-Yes, callouts can be made within a Batch Apex job by implementing the `Database.AllowCallouts` interface. This allows the batch job to make external HTTP requests as part of its processing.
How is error handling implemented in Batch Apex?
-Error handling in Batch Apex is implemented by implementing the `Database.ErrorPlatformEvent` interface. This event is automatically fired whenever an error or exception occurs within the batch job, allowing you to handle errors in a centralized manner.
What are some key limits of Batch Apex that a developer should be aware of?
-Key limits of Batch Apex include: a maximum of five jobs can be queued or active at a time, a maximum of 50 million records can be processed if using `Database.QueryLocator`, a maximum of 10 callouts can be made from each of the start, execute, and finish methods, a maximum of 250,000 batch executions are allowed per 24 hours, and only one batch Apex start method can run at a time in an organization.
What is the default batch size for Batch Apex if the optional scope parameter is not used?
-The default batch size for Batch Apex, if the optional scope parameter is not specified, is determined by Salesforce and typically allows for efficient processing within the governor limits.
How can you execute a batch job from the developer console?
-To execute a batch job from the developer console, you would typically use the `System.enqueueJob()` method, passing in an instance of your batch class.
How can you execute a schedulable job from the developer console?
-To execute a schedulable job from the developer console, you would call the `System.schedule()` method with the appropriate parameters, such as the job's class and any required arguments.
Outlines
π€ Apex Interview Q&A Series Introduction
In this video segment, the speaker, Jen, introduces part five of the Apex interview preparation series on her YouTube channel, 'The Journey with Jen.' She outlines the content of the video, which includes answering frequently asked questions about asynchronous Apex based on community inputs from LinkedIn and YouTube comments. Jen encourages viewers to continue submitting questions and to connect with her on various platforms. The first topic discussed is the limitation of the 'future' method in Salesforce, specifically why it doesn't support 'SObject' data types.
π Future Methods and Their Limitations
This paragraph delves into the restrictions and recommended practices when using 'future' methods in Salesforce. It explains why 'future' methods only accept primitive data types and not 'SObject' types, due to the potential for data changes during asynchronous execution. The recommended approach is to pass IDs and query the latest records within the 'future' method. An alternative, though not recommended, method involves serialization and deserialization of 'SObject' data. The paragraph also covers other 'future' method limitations, such as the inability to chain 'future' methods or call them from batch jobs, and provides the maximum number of 'future' method invocations allowed per transaction.
π Batch Apex Fundamentals and Best Practices
The speaker provides an overview of Batch Apex, discussing its structure, methods, and best practices. Batch Apex is composed of three mandatory methods: 'start', 'execute', and 'finish', each serving a specific purpose in the batch process. The 'start' method is responsible for record collection, 'execute' performs the operations on these records, and 'finish' is used for post-processing tasks. The paragraph also addresses the differences between 'Database.QueryLocator' and 'Iterable' interfaces in Batch Apex, explaining when to use each based on the scenario, such as processing large datasets or iterating over records in a customized manner.
π Deep Dive into Batch Apex Interfaces and Error Handling
This section offers an in-depth look at the interfaces used in Batch Apex, such as 'Database.QueryLocator' and 'Iterable', and their specific use cases, like handling large datasets or custom record iteration. It also introduces the concept of 'stateless' and 'stateful' Batch Apex, explaining how stateful implementations can maintain information across multiple transactions. Additionally, the paragraph covers the ability to perform callouts within Batch Apex and the importance of error handling through the 'Database.PLATFORM_EVENT' interface.
π Batch Apex Execution Limits and Practical Considerations
The final paragraph focuses on the key limitations and practical aspects of executing Batch Apex. It highlights the maximum number of jobs that can be queued or active at a time, the limits on record processing, and the constraints on callouts within the 'start', 'execute', and 'finish' methods. The paragraph also touches on the maximum number of batch executions allowed within a 24-hour period and the rule that only one Batch Apex 'start' method can run at a time, while multiple 'execute' methods can run in parallel.
Mindmap
Keywords
π‘Apex
π‘Future Method
π‘SObject
π‘Asynchronous Execution
π‘Batch Apex
π‘Database.QueryLocator
π‘Iterable
π‘Stateful
π‘Callout
π‘Error Handling
π‘Governor Limits
Highlights
Introduction to part five of the Apex interview preparation series with Jen.
Discussion of frequently asked questions based on asynchronous Apex.
Explanation of why Future methods do not support SObject data types.
Recommendation to pass IDs instead of SObjects in Future methods.
Alternative approach using serialization and deserialization of SObjects in Future methods.
Clarification that chaining Future methods is not possible.
Limitation that Future methods cannot be called from a batch job.
The limit of 50 Future method invocations per transaction.
Inability to schedule Future methods for periodic execution.
Key limitations of Future methods, including primitive data type support and lack of tracing.
Introduction to Scheduled Apex, including the maximum number of jobs that can be scheduled.
How to find scheduled jobs in Salesforce and the use of the Cron Trigger object.
Scheduled Apex does not support call-outs, but workarounds are available.
Explanation of how to count the number of scheduled jobs using the Cron Trigger object.
Sample Batch Apex class example for beginners, emphasizing the importance of implementing interfaces and methods.
Description of the three methods in Batch Apex: start, execute, and finish.
Difference between Database.QueryLocator and Iterable in Batch Apex.
Use case for Iterable interface when processing CSV files in Batch Apex.
Stateful vs. stateless Batch Apex and when to use each.
How to implement call-outs in Batch Apex using the Database.AllowsCallouts interface.
Error handling in Batch Apex through the Database.ErrorPlatformEvent interface.
Key limits of Batch Apex, including the number of queued jobs and record processing limits.
Invitation for viewers to attempt answering additional questions related to Batch Apex.
Closing remarks and call for comments and further questions from the audience.
Transcripts
[Music]
hello everyone my name is an Jen and I
welcome you all to my channel te Journey
with
anit this is part five of our Apex
interview pration series and in this
part we'll be discussing the frequently
asked questions based on
asynchronous before this part we have
published few more interview PR series
part and in this series we are
discussing all those questions that you
folks only have shared with me either on
LinkedIn or on my YouTube comments
videos as well
so in case there are a few more
questions that you want me to cover do
let me know again in the comment section
I will make sure that to cover those in
the future videos as well so if you
folks like to connect with me you can
definitely subscribe to my YouTube
channel you can connect with me on the
LinkedIn and also join our telegram
channels as well where we discussed all
the different types of questions that
you folks only encounter in your
preparation
Series so the first question that we'll
be discussing for today is why does the
future method not support the S object
data type we all know that in the future
method we can only pass the primitive
data type that we all know but most of
the times I have seen that people not
able to answer why the Salesforce
restrict to not pass the S object data
type as an argument the reason being
here is it is not guaranteed that when
your future method will be execute so
that the S objects that you are passing
it as an argument might change when the
future method will be executed and for
that reason Sal force does not allow you
to pass the S object type as a
parameter the way you should handle this
kind of a scenario here is you should
pass the ID and in your future method
you should go and make the query on
those record as you can see in this
example what we are doing here is we are
passing here the ID and after passing
the ID we are fing the latest s object
record so that is the recommended
approach from the Salesforce whenever
you have to work on the S object but
many times I have seen that people do
apply one alternate way to handle this
kind of a scenario where they are sure
that your s object will not be changing
although I'll not recommend to go for
that approach but in case in your
interview they have asked for the
alternate way you should also say that
by using the d uh serializing and the
deserializing approach you can pass the
S object the way you should do this here
is in your future method you will accept
the input as a string and as soon as you
receed the input as a string you should
go and deserialize it however while
invoking the future method in case you
have to pass any s object pass it in the
form of serialized way so as soon as you
are receiving the serialized string in
the first statement in your future
method should be go and deserialize that
and process the S object again I'm
repeating it's not the recommended way
it just an alternative way to do
that so there are few frequently asked
questions mostly a oneliner question
questions that you should know uh if you
are appearing for the interview for
example can we call a future method from
another future method the answer is no
the chaining is not possible with the
help of future method and that is
another limitation of the future method
so we cannot call another future method
from one future method another question
here is can we call a future method from
a bad job again the answer is no we
cannot call a future method from a bad
job as well the reason being we
discussed in the last session or I
believe we discussed in the today's
session as well that maximum 50 future
jobs can be invoked in one transaction
if you are invoking the future methods
from the batch Apex if there's high
probability of hitting the limits that's
why sales for does not allow you to do
that again there's a workaround for here
as well uh I have seen manyu of blogs
many blogs over the web where they have
put a work around that you can do that
using the web service personally I have
never tried so I cannot comment on that
but yes that is also one of the approach
that is possible next one here is what
is the limit on the number of future
methods invocation per transaction just
now I'm talking about the limit of
future methods that you can invoke in
per transaction is 50 and because of
this limit only Salesforce does not
allow you to invoke the future methods
from batch UPS next one can you schedule
a future method to execute for
periodically no again we cannot schedule
the future methods they are designed for
the onetime asynchronous execution ution
approach so scheduling of future method
to execute periodically is also not
possible next one here is what are the
key limitations of the future methods
that you should keep in mind first one
here is future methods are not something
which you should use whenever you have
to process the large set of Records
process the large set of Records
Salesforce have a specific asynchronous
Opex approach that is the batch so you
should go for that option only as I said
we cannot invoke one future method from
another future method so chaining is
also not possible with the help of
future method next this one also we
discuss just now it only supports the
primitive data types you cannot pass s
objects or collection of s objects as a
parameter whenever you are working on
the future method and the tracing is not
possible with the future method
programmatically you cannot track
whether the future method is completed
or not this is possible to achieve in
other asynchronous approach like the
quable schedulable or the batch appex
but it is not possible to do that
because whenever your future method is
submitting it is not returning the job
ID and as you don't have the job ID it
is not possible to do that tracing next
one here is it can't be called from the
batch that is another limitation of the
future method it cannot be called from
the
batch another few questions and these
questions are specifically based on the
scheduel Apex now what is the maximum
number of jobs that can be scheduled at
a given time so in your hug you can only
schedule maximum 100 jobs and how you
will find which jobs are scheduled so
for that you have to go to the setup and
in the setup you will put the scheduled
jobs you will see all the scheduled jobs
in your Aug another question here is
does scheduled effect support the call
out again the answer is no your
scheduled aex does not support the call
out but there are two work arounds that
you can do that you can do that by
invoking the future method where the
future method is annotated as call out
is equal to true you can also do that
from the batch aex as well next one here
is how to count the number of schedule
jobs so whenever you have to count any
schedule job you have to go for the
object that is the crown job details
object and in sorry in the you have to
go to the crown trigger object and in
that Crown trigger object you will look
for the crown job details. job type is
equal to
s here represents the scheduel Apex so
whenever you have to programmatically
count how many number of schedule jobs
has been configured you will make a
query to the crown trigger object okay
this is how you can achieve it next one
can you write a sample batch PEX class
again many times I have seen that
specifically for the freshers this
question has been asked uh where they
will ask you to write down the batch
effect again here the intent is not to
check the tax but to remember whether
you should remember to implement the
particular interface or not whether you
should remember to write down the
particular method names or not right
start execute and finish method whether
you are able to write down these methods
or not right whether you are able to put
the correct return return type for the
start method or not okay so your start
method have the two return types either
you can go for the databasequery locator
or you can go for the itable as well so
here I'm giving an example of a database
do query locator where I'll be putting
the query and return those records as
well okay so this is how the typical
batch Apex class will look like so make
sure that this you should definitely
practice by writing down the batch aex
class by yourself you can keep writing
the class something like this make sure
you executing it as
well next question can you explain about
the three methods of the batch appex as
I shown you we do have the three methods
available in the batch appas one is the
start method second is the execute
method and third is the finish method
now the question here is what is the
significance of each and every method
which is available in the batch Apex so
the first method that we do have here is
the start method this method will be
automatically called at the beginning of
the Apex job the first method of the
batch appex that will be called here is
the start method this method is
basically responsible to collect the
records that needs to be processed by
the batch Tex so the main purpose of the
start method here is the collection
method collection of Rec second one here
is the execute method execute method
performs an operation which we want to
perform on those record so whatever the
uh business logic that you have to
execute on the selected records you will
put that business logic into the execute
method and the third one is the Finish
method finish method will execute after
all the batches has been processed in
case you have to send any confirmation
email or you have to submit another bad
job you can do all those stuff under the
Finish method again these methods are
mandatory to implement whenever you are
using the database. batchable interface
if you are not implementing any of this
method you will get a compile time
error next one as I said your start
method can have the two return types one
is the database do query locator and
another one here is the iterable as well
so first let's go and talk about what is
database. query locator when you should
go for the database do query locator and
when you should go for the itable
interface so in your start method if you
are to include the code that can collect
the records method and then pass those
collected records to the execute method
then you should go for the database.
query locator the key part to identify
with the database. query locator here is
by using this you can query up to 50
million records using this you can query
up to 50 million record so in case you
do have a requirement where where you
have to directly make a query on the S
objects and F those records prefer to go
for the database do query
locator because by using this database.
query locator you are passing the limit
of the SQL queries you guys have to let
me know in the comment section how many
records we can Fage by using the SQL
query right and that limit we are
bypassing by using the database. query
locator so if the start method returns
at query Loc
optional scope parameter this parameter
is also very important whenever we are
executing the batch aex we always pass
the optional scope parameter right it's
not mandatory in case you are not
passing then what is the default value
again do let me know in the comment
section I believe I do have that covered
in the upcoming slides as well but in
case you have watched till here do let
me know what is the default value of the
optional scope parameter so if you are
not passing that value it will work on
that value but in case you are passing
that value then the maximum value that
you can put here is the 2,000 so in the
case of database. query locator the
maximum value of the optional scope
parameter here is 2,000 these are the
three key point that you should be
answering whenever anyone ask you about
the database do query locator and if
this they ask you to write down the
syntax this is how it will look like you
have the database do query locator as
the return type in the start method and
how to return those records for that we
have to to execute the method database.
getquery locator okay and here you can f
up to the 50 million
R next one here is the iterable
interface in the batch appex now what is
the need of having the two interfaces
one is the database. query locator and
second is the itable I have seen many of
the people not worked on this itable
interface and this question specifically
comes for the experiened professional
right so they might ask you whether you
have worked on the ital interface and if
you said yes they they might ask you the
specific scenario okay so the specific
scenario that I work in my experience
here was whenever I have to go and
process the CSV file into the batch Apex
I have preferred to use the itable
interface okay so in the start method
you can include the code provided the
developers with the power to iterate
over the record so where you should go
and Define this interface in the start
method you should go and Define that
interface you will provide the code uh
with the power to iterate over the
records in a highly customized manner in
the case of database. query locator what
you are doing you are making the records
queried from the S object but what if
you already getting let's say collection
or in my scenario as I explained I am
already having the CSV file I have to
process that collection or the CSV file
it is not possible to do that by using
the database. query locator for example
I have to put an highly customized way
of iterating the records again that is
not possible with the database. query
locator so in such scenarios we will go
for the iterable interface so using the
iterator interface you can create a
custom set of instructions that's what
it is allow it will allow you to write
down the custom set of instructions for
traversing a list through the loop okay
you can Traverse any correction for
example as I said you do have the huge
number of Records available in the
collection and you have to process those
records one after the other using the
batch appex your the option for you is
to go for the itable interface if you
use an itable again that is this is what
you have to keep you remember with
respect to the governor limit if you are
using the itable interface then you
still have the governor limits imposed
by the S soql query so the point here is
if you are using the iterable interface
you cannot make or you cannot fish or
cannot process 50 million
records okay that option is not possible
if you are using the itable interface so
50 million record option is only
possible whenever you are going for the
database do query locator it is not
possible with the iterable interface so
this is how the typical syntax of the
iterable interface will look like here
the return type is
itable right here the return type is
iterable and what you have to return
here here is your itable class so for
example in this scenario this is my
itable class and I am returning the
instance of the iterable class now how
to implement this iterable class so I
have put some snippet here for your
reference so for example here you can
see this is my itable class which is
implementing itable
interface and as we are implementing
this itable interface it is mandatory to
implement the
iterator it is mandatory to implement
the iterator now here I have implemented
the iterator method and what is the
return type of my iterator it is the
iterator of account
what is the return type here is the
iterator of account and what I am
returning from this method is the
iterator of account and this is how my
iterator method will look like so here
you can see that I do have a class which
is implementing this iterator method and
now I'm implementing the iterator method
it is mandatory to implement the two
methods this is the first method that is
has next and second one here is the next
method has next method will decide
whether there's a next record is
available to process or not that will be
def by the has next method what needs to
be processed whether the record needs to
be processed or not what business logic
needs to be process you will put that
logic under the next
method okay so for example if I have to
run this example what I am doing in my
iterator example here is I am making the
query on the
account okay and what I have to do here
is I have to only process the eight
records a hypothetical scenario
definitely many of you will say that it
is possible to achieve using the limit
but just for our understanding I don't
want to do it with the limit uh I want
to do it as an iterator interface here
so what I am doing here is I have put
here I is equal to 8 I checking when the
I value is incrementing to 8 or not I
have initialized this value to zero so
when my first time this method will
execute right it will check whether the
I value is greater than the account size
the answer is
yes it will go and return me that
account right like this I am checking
unless and until I am meeting this
criteria if I meet this criteria then
and then only I will stop
processing so this is how you can go and
use the iterator method whenever you
want to have the custom control how to
process
those now next question here is what is
the state in the batch appex or what is
database.
stateful very frequently Asked question
specifically for the PR and also for the
experience professional as well what is
state in the batch appex so do remember
that by default your batch appex is
stateless what does the stateless means
if the batch appex have processed some
information in the first batch of
execution it will not be carried forward
in the next batch so that's what I have
put up here if a batch process and needs
information that is shared across
transaction then you have to go and use
the stateful interface by default it is
stat list if you are putting the stat
list means the information that you have
processed in the previous batch it is
not carried forward in the next batch if
you have to make sure that the
information is needs to be shared across
the multiple transactions then go and
use the database. stateful interface if
you specify the database. stateful in
the class definition you can maintain
the state across this
transaction across the transaction you
have to maintain the state go and
implement this for example if your
batchable job is executing one logic and
you need to send an email at the end of
the batch job where you have to go and
put how many successful records and the
failed records so what you have to do
here is here you have to go and send the
summary of how many successful records
that you have processed how many failed
records that you have processed and you
want that count should be coming up
across the batches right not from one
single batch then in such scenarios you
go and implement the dat database.
stateful interface so this is an example
how you should do that so here you will
be putting up my bad job right and here
you have to make sure that you are
implementing this interface if you are
implementing this interface whatever the
primitive data types that you have
defined here this Prem data types will
hold the values across the transaction
so here you can see that I have
initialized that value as zero and in my
multiple batches I am incrementing the
value so what will happen how many
records that has been processed by this
particular variable if I have to check
under the Finish method I can easily do
that because now I have implemented the
database. stateful that means the value
of this variable will be persisted
across the multiple batches as well very
helpful interface very frequently we use
in our real world examples as
well next one can we do the call outs in
the batch ofex again the answer to this
is yes we can do the call outs in the
batch aex as well and to do the call
outs we have to implement another
interface that is the database do
callout
interface we have to go and Implement
another interface that is the database.
Hout interface and this is how the
syntax will look like here you have to
go and specify database. allow Callum
sorry it's it's a typo from my side
right but this is the correct interface
name that you have to implement
database. allows column
next one how to do the error handling in
batch app and this is again one of the
favorite question specifically for the
experience professional how you can do
the error handling in the batch X and
the very good part here is it is very
easy to implement so any batch Apex can
Implement an interface here that is the
database. race platform event so this
event will be automatically invoked
automatically fired whenever your batch
upex encounter any error or exception so
your answer should be to implement the
error handling in the batch appex we
should go and Implement an interface
that is database. R platform event and
this interface will be sorry this event
will be automatically invoked whenever
any error or exception occurred in our
code how to implement that it's very
simple database. R
platform I have put a very detailed
video how you can go and do the error
handling with the help of of batch aex
under my platform event series if you
are preparing for it and want to know
more about the error handling in the
batch aex make sure that you folks check
that out as well here there I have
written down the code and actually shown
you the scenario how the multiple task
will be created in case any error Ed in
your batch Appice so do check that
out now what are the key limits of the
batch aex that you should know for the
batch aex the key limit that you should
know here is to five job can be queued
or at a time active for the batch up to
five cued or active jobs are allowed for
the batch your batch appex can process
million record if you are using the
database. query locator in case there
are more than 50 million records again
your batch appas will terminate
immediately and will Mark that complete
process as failed next one here is the
start execute and finish method can
Implement 10 call outs each so in the
start method execute method and the
Finish method you can implement the 10
call out each next one this limit is
very important the maximum number of
batch execution here is
250,000 250,000 for 24
hours the maximum number of batch
execution here is 250,000 per 20 4 hours
again if you are hitting the limit your
batch appex will not be processed and
the last one here is which is again not
known to many people only one batch aex
job start method can run at a time in an
organization in your or at a time only
the one patch effect start method is
running in case that method is running
other methods will be into the queue
again they they will not fail they will
be stay they will be in the queue right
however multiple exec methods can run in
parallel so keep a note that only one
start method can be running at a time
batch aex that haven't started yet
remain in the queue until they are
start now these are the few questions
that I want you guys to attempt and let
me know the answers in the comment
section the first one here is what is
the batch size if we don't use the
optional scope parameter what is the
default bat size for the batch effects
next one here is
how you can execute the badge job which
method you will use to execute the badge
job which method you will use to execute
the quable job and which method you will
use to execute the shable job the
schedulable job can be executed by a two
approach first one from your UI approach
so I'm not asking here about from the UI
I'm asking about from the developer
console if I ask you to execute the
schedule level appex which command you
will use and what parameters you will
pass
again I do insist do try to attempt this
questions the reason I give this
question as I mentioned in the past
videos as well so that you can you you
are also encouraged to do your own self
study as well I hope you folks found
this video helpful do let me know in the
comment section if you do have any
questions or any queries or your thought
about this series as
well moreover any other question that
you think we have not covered in this
series and we should be covering it
again again let me know in the comment
section thank you folks that's all I do
have for today bye-bye
[Music]
5.0 / 5 (0 votes)