• Ardilla Lestari
  • 0 Points
  • Member since 2019

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2

Hi all,

We need to implement the following pattern at my org:
  • callout to external data source
  • if that callout takes too long (according to some configurable threshold), log an error (ie do some DML)
  • if that callout timed out on the remote server, try it again
Recognizing the potential for the dreaded "You have uncommitted work pending. Please commit or rollback before calling out." error, I put the error logging code in a future method, thus isolating the DML from the callouts. However, the error is still being thrown. I reduced the issue down to this pattern:
public static void foo() {
    Http http = new Http();
    HttpRequest req = new Httprequest();
    req.setEndpoint('https://test.salesforce.com'); //whatever endpoint
    http.send(req); //works fine
    http.send(req); //throws calloutexception

@future public static void bar() {

Am I correct to assume that calling a future method counts as a DML operation? Is there any documentation I'm missing somewhere?

I am trying to create a validation rule to enforce users to fill out a lookup field based on a multi-select. Here is the trick

Multi-Select has 3 options(A,B,C) and we have 3 different lookups called A,B,C

If I select A from the picklist then I have to fill out lookup A
If I select B then fill out lookup B
If I select C then fill out lookup C 


if I select A,B fill out lookup A,B
if I select A,C - then lookup A, C
if I select B,C - then lookup B,C 

Any thoughts how I can write this validation?