You need to sign in to do that
Don't have an account?
Arjun y 7
How to hit multiple times to external server from salesforce
Hi All,
Requirement is we need to do update operation in salesforce from SAP. The job should runs every day.
In SAP, we have 30000 records. When we hit the SAP server, we have to receive entire 30000 records in one call using REST Api. I tried this and am getting this error "System.StringException: String length exceeds maximum: 6000000" Can i know is there any other approach to work on?
Requirement is we need to do update operation in salesforce from SAP. The job should runs every day.
In SAP, we have 30000 records. When we hit the SAP server, we have to receive entire 30000 records in one call using REST Api. I tried this and am getting this error "System.StringException: String length exceeds maximum: 6000000" Can i know is there any other approach to work on?
Thanks for the reply. In our requirement, from salesforce we need to hit the SAP server to fetch 30000 records. For this, they are giving pagination url to us. So, we need to hit the 30 times to that server to pull the data.Currently, i am working on it.
I have tried with the rest approach. I am recieving heap size limit.
Please let me know if there any other approach to hit 30 times to the external server to pull the data?
Thanks
We are not using any middleware for this integration. From salesforce, we need to hit the SAP server multiple times to fetch the data and need to do record updates in salesforce. For this, SAP gave odata pagination URL which gives 1000 records for one transaction.
Thanks
Once you have filled the gaps in the class SAPToSFDataLoader with your application logic, just invoke
from your Developer Console. The scueduler will be scheduled to run at 12.01 AM every day.
Here is what the above code does:
1. The schedule "SAPToSFDataLoadScheduler" is invoked at 12.01 AM
2. It queues "SAPToSFDataLoader" to run in default mode (no page index specified)
3. The "SAPToSFDataLoader" runs when system resources are available and depending on its mode (argPage), makes a callout to SAP
4. "SAPToSFDataLoader", fetches, processes and determines the next page for processing. If next page is available, it Queues a new instance of itself to process the next page from SAP.
This solution is scalable, in case if you have records that exceed 30000.
Hope this helps
Here are some useful links on Queueable
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_queueing_jobs.htm
https://developer.salesforce.com/blogs/developer-relations/2015/05/queueable-apex-future.html
https://developer.salesforce.com/blogs/engineering/2014/10/new-apex-queueable-interface.html
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Queueable.htm
Thank You for the above technique. I have one query regarding this.
if(mPage == -1) {
// Do the first callout to SAP here and assign records to lRecordsFromSAP
}
If i made first call here, will it be pull all 30000 records at once?
To achieve this, i went for batch class methodology and it is working for me now.
Thanks.
I used below technique.It is working for me.
public with sharing class CalloutBatchApex implements Database.Batchable<Integer>, Database.AllowCallouts {
public Iterable<String> start(Database.BatchableContext BC) {
return new List<Integer> { 1, 2, 3 };
}
public void execute(Database.BatchableContext info, List<integer> iteration) {
// Make the callout to the web service and import the records to Salesforce for the iteration.
}
public void finish(Database.BatchableContext info) {}
}
Can you please send the full code?
I need to import about 1000 records every day from external system to salesforce using api. Is it acheivable using http callouts?