function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dan Dodd 3Dan Dodd 3 

Add to and use a queue for external http requests

I'm wondering what queue method I should use.
I want to use a trigger to enqueue an external httpRequest:
When a contact is created,  if it has a value in a custom field , add to the queue. 
The process servicing the queue will post that custom field to an external server and get the additional data associated with that customer field value. Then it will update the contact.
I am open to other ways to accomplish this.
trigger ContactTrigger on Contact( after insert )
  // Create a List of Contacts that will be used for processing
  List< Contact > cList = new List< Contact >();

  // Obtain a list of Contacts that will fulfill your conditions
  for ( Contact c : ) if ( c.custom_field__c != null ) cList.add( c );

  // Run the queue on the custom contact list
  Id JobId = System.EnqueueJob( new YourQueueClass( cList ) );

Something like this?
Dan Dodd 3Dan Dodd 3
What I have done is to have the trigger set a field rather than enqueue a job. I still need to bulkify it.
Then scheduled a recurring job to check conditions and make the callout if records found. 
Thats the theory anyway, we'll see. Thx