My process -
I have a process in which I send data to outer system - and get a JSON to insert into Salesforce. This is handled by a scheduled class once a week.
The Received JSON: - (Could be ~7K Contact).
{
"Contact": [{
"Name": "emxampleName",
"Email": "[email protected]",
"Age": 123456789,
"contact_External_Id":"123456",
"Courses": [{
"Name": 12354678,
"Contact_Person": 2,
"Exam_Date": 1234567
}],
"Scholarship": [{
"Name": "U",
"donor_Name": 1234,
"Total_Sum": "5000"
}]
}]
}
For the Scholarship & Courses Objects (Also objects in salesforce which Contact is the parent) I should check if I need to insert or update the Data, base on a few keys For the Contact itself - only with one external field key - so I can use UPSERT.
I thought to Insert all the contacts first - without the Courses and Scholarship - and send to the batch all the Ids of the upserted contact.
After that, inside the batch - for each contact - I will seek the "contact_External_Id" and check if I will need to insert\update the Scholarship & Courses.
My questions -
Until now I used Future method with callout to run the request and get the data - but since I need to push the data to a batch and run the query on the set of the contact Ids - I can't use this method anymore (Can't call Batch from future method). How can I achieve it?
This process solution sounds a bit lame. If you guys have a better solution - It will be much appreciated.
Many Thanks!