The ws_contact_callout class expects a SET of ids. in the Execute methods I attempt to get it but within the loop but the compiler is complaining.
How can/should I get the Set of ids without requery?
public class sync_mdm_contact_batch_V2 implements Database.Batchable<sObject>,
Database.Stateful , Database.AllowsCallouts
{
public integer recordCount = 0;
public Database.QueryLocator start (Database.BatchableContext bc)
{
return Database.getQueryLocator('SELECT Id FROM Contact WHERE RecordType.DeveloperName = \'xxx\'');
}
public void execute(Database.BatchableContext bc, List<Contact> scope)
{
//variable does not exist: records
Set<Id> ids = new Map<Id, Contact>(records).keySet();
//process each batch of contacts
for (id recordid : ids)
{
//method does not exist on incorrect signature: void future_callout(id) from the type ws_mdm_contact
//Signature for ws_mdm_contact.future_callout(Set<ID> ids)
ws_mdm_contact.future_callout(recordid);
//increment recordsProcessed
recordCount += ids.size();
}
}
public void finish(Database.BatchableContext bc)
{
system.debug(recordCount + 'records processed');
AsyncApexJob job =
[ SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email
FROM AsyncApexJob
WHERE Id = :bc.getJobId()
];
//email
emailManager.sendMail('email', 'subject', string.valueof(recordCount));
}
}
This is my first attempt at a batch class following the trailhead example with a twist. In the Execute method I want to be able to send 100 records (set of ids) to my class which does my callouts. If I rightly understand things I can have up to 100 callouts. So this should get me 100 records x 100 callouts aka 10000 records.
reported issue:
Getting closer I can almost taste it. I updated the code to reflect current state and commented where it is complaining. The endpoint is constructed to only handle one record at time so I think I need to do the loop vs a bulkcall.