3

I am a beginner when it comes to Apex and am trying to set up a trigger for Adobe Echo Sign to send a new contract request automatically when a new custom object record is created (something Adobe said I would not have to do during the sales stage of this whole process). Anyway, I cannot figure out why this trigger is failing. Any help at all is greatly appreciated!:

trigger EchoSignSendAgreement on Credit_Application__c (after insert) {
  List<Credit_Application__c> creditApplications = Trigger.new;
      echosign_dev1__Agreement_Template__c tem= [Select Id from echosign_dev1__Agreement_Template__c Where Name='Standard Credit Application'];

      for (Credit_Application__c creditApplication : creditApplications) {
            SendAgreement_Methods.sendAgreement(tem.Id , creditApplications.name );
       }   
    }

public class SendAgreement_Methods {

    @future (callout=true)
    public static void sendAgreement(Id temId, Id Name) {
        try {
            System.debug('Calling AgreementTemplateService.load: ' + temid + ' - ' + Name);
          echosign_dev1.AgreementTemplateService.load( temid , Name);

        } catch (Exception E) { System.debug('Exception: ' + e.getStackTraceString());}       
    }

}
3

You're trying to define a class and trigger in the same file. It can't be done. Separate them into the proper files.

EchoSignSendAgreement.trigger

trigger EchoSignSendAgreement on Credit_Application__c (after insert) {
    List<Credit_Application__c> creditApplications = Trigger.new;
    echosign_dev1__Agreement_Template__c tem= [Select Id from echosign_dev1__Agreement_Template__c Where Name='Standard Credit Application'];

    for (Credit_Application__c creditApplication : creditApplications) {
        SendAgreement_Methods.sendAgreement(tem.Id , creditApplications.name );
    }   
}

SendAgreement_Methods.class

public class SendAgreement_Methods {

    @future (callout=true)
    public static void sendAgreement(Id temId, Id Name) {
        try {
            System.debug('Calling AgreementTemplateService.load: ' + temid + ' - ' + Name);
          echosign_dev1.AgreementTemplateService.load( temid , Name);

        } catch (Exception E) { System.debug('Exception: ' + e.getStackTraceString());}       
    }

}
0
3

You need to keep separate class and trigger. Only keep the below code in trigger file.

trigger EchoSignSendAgreement on Credit_Application__c (after insert) {
  List<Credit_Application__c> creditApplications = Trigger.new;
      echosign_dev1__Agreement_Template__c tem= [Select Id from echosign_dev1__Agreement_Template__c Where Name='Standard Credit Application'];

      for (Credit_Application__c creditApplication : creditApplications) {
            SendAgreement_Methods.sendAgreement(tem.Id , creditApplications.name );
       }   
    }

Create separate class for:

public class SendAgreement_Methods {

    @future (callout=true)
    public static void sendAgreement(Id temId, Id Name) {
        try {
            System.debug('Calling AgreementTemplateService.load: ' + temid + ' - ' + Name);
          echosign_dev1.AgreementTemplateService.load( temid , Name);

        } catch (Exception E) { System.debug('Exception: ' + e.getStackTraceString());}       
    }

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.