• Gareth Nguyen
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Hi guys,

I am having an issue when trying to implement Enqueue. The error says that the constructor is not defined.
Constructor not defined: [job1].<Constructor>(List<Account>)
I have a trigger that enqueues a class:
trigger CreateAccount on object (before insert) { 
        if (Trigger.isBefore && Trigger.isInsert) { 
                   System.enqueueJob(new job1(Trigger.new)); 
        } 
}
Here is the class that I am devloping:
public class job1 implements Queueable{ 
          public static void job1 (List<Account> Acc) { 

          } 

          public void execute(QueueableContext abcs) { 
                   actions .... 
          }
}

How can I fix this error?

Thank you.
Hi guys,

I am having difficulties finding way to solve the issue that one of my trigger actions triggers another action, it throws the AsyncException.

Here is my Trigger, it will trigger before an account is inserted into the object:
trigger createaccount on object(before insert) {
    if (Trigger.isBefore && Trigger.isInsert) {
        createaccountrec.onBeforeInsert(Trigger.new);
    }
}
The trigger calls the method that invokes another action that calls and gets data from API
private static void AccHandler(String accdomain) {
                Http http = new Http();
                HttpRequest request = new HttpRequest();
                request.setEndpoint('api request link');
                request.setHeader('Authorization info');
                request.setMethod('GET');
                HttpResponse response = http.send(request);
                Map<String, Object> res = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
                Map<String, Object> var = (Map<String, Object>) res.get(part here);
                String companyName = (String) var.get(field here); 
                Account newAccount = new Account();
                newAccount.Name = companyName;
     	        insert newAccount;
            }
        }
    }
    
    public static void createaccountrec(list<object_name> recAccs) {
        for (object_name recAcc: recAccs) {
            if (!Test.isRunningTest()) {
				AccHandler(recAcc.field);
            }
        }
    }
How can I solve the Assync Exception issue here? I try to put @future(callout = true) but it doesn't work either. This code runs normally if I try to insert account manually, however it will throw the exception if any action, integration try to insert account.

Thank you so much.