Hi Kavya, If you want to invoke a batch class from the SAP system then you can have to integrate the SAP with Salesforce. Where you will send any sample request to salesforce and salesforce will call the batch class with the help of web service.
Here are the some references : https://trailhead.salesforce.com/en/content/learn/modules/apex_integration_services/apex_integration_webservices https://jayakrishnasfdc.wordpress.com/2018/09/09/apex-rest-web-services-example/
@RestResource(urlMapping=’/ExecuteBatch/*’)
global with sharing class MyRestResource {
@HttpGet
global static Account callBatch() {
// Add your code
//Call Batch Class here.
}
}
Thanks for your response. I tried as per the code you mentioned. Since this batch class is all about sending emails what shoud be the return type of the Method?
@RestResource(urlMapping='/ExecuteBatch/*') global with sharing class MyRestResource { @HttpGet global static <Object> callBatch() { BMC_SendEmailToDistributorContact sendEmail= new BMC_SendEmailToDistributorContact(); database.executeBatch(sendEmail,1);
Hi Kavya, There is no need for return type when you call a batch class. It's asynchronous execution. IF you want you can send an email or update or insert a record in the finish method of the batch. So you can get an update when the batch will be finished.
Hi Kavya,
If you want to invoke a batch class from the SAP system then you can have to integrate the SAP with Salesforce.
Where you will send any sample request to salesforce and salesforce will call the batch class with the help of web service.
Here are the some references :
https://trailhead.salesforce.com/en/content/learn/modules/apex_integration_services/apex_integration_webservices
https://jayakrishnasfdc.wordpress.com/2018/09/09/apex-rest-web-services-example/
Hope this helps you.
Thanks
Deepak
Thanks for your response.
I tried as per the code you mentioned. Since this batch class is all about sending emails what shoud be the return type of the Method?
@RestResource(urlMapping='/ExecuteBatch/*')
global with sharing class MyRestResource {
@HttpGet
global static <Object> callBatch() {
BMC_SendEmailToDistributorContact sendEmail= new BMC_SendEmailToDistributorContact();
database.executeBatch(sendEmail,1);
}
}
Hi Kavya,
There is no need for return type when you call a batch class. It's asynchronous execution. IF you want you can send an email or update or insert a record in the finish method of the batch. So you can get an update when the batch will be finished.
Thanks.