You need to sign in to do that
Don't have an account?
Sandesh D Ganjare
How to insert delay in apex class?
Hi,
I am new to salesforce. I have an apex class from where I am calling a web service. I want to insert the delay of 10 sec so that I can handle the 'over query limit' error.
thanks in advance!
I am new to salesforce. I have an apex class from where I am calling a web service. I want to insert the delay of 10 sec so that I can handle the 'over query limit' error.
thanks in advance!
Check if future annotation can be added for your scenario -
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_future.htm
public static void sleep(Integer secs ) {
datetime myStartDateTime = datetime.now();
DateTime newDateTime = myStartDateTime.addSeconds(secs);
while (datetime.now() < newDateTime ) {
// sleeping here...sort of
}
datetime myEndDateTime = datetime.now();
System.debug('start: ' + myStartDateTime ) ;
System.debug('end: ' + myEndDateTime) ;
}