[SalesForce] Error: Compile Error: unexpected token: public at line 10 column 0

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());}       
    }

}

Best Answer

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());}       
    }

}
Related Topic