Skip to main content
Participant
November 24, 2023
Question

Using Apex to send agreement for E Sign ,

  • November 24, 2023
  • 1 reply
  • 405 views

Hi I am facing a challenge in sending Agreement for e sign with template ID. In template the AutoSend checkbox is checked. Below is the code. There is a custom object WorkOrder which will be created trough a queueable job when Opp reaches at a certain stage. The Class whic creating the workorder will then make an another queuebale exceute which will call the below code 

public class QueueableWorkOrderAgreementTemplateSend extends QueueableBase{
    Set<Id> workOrderIds;

    public QueueableWorkOrderAgreementTemplateSend(Set<Id> workOrderIds) {
        this.workOrderIds = workOrderIds;
    }

    public override void executeLogic(QueueableContext context) {
        if(workOrderIds!=null && !workOrderIds.isEmpty()){
            List<WorkOrder__c> woforSign = (WorkOrdersSelector.newInstance()).selectWorkOrders(workOrderIds);
            Map<String,echosign_dev1.AgreementTemplateVariable> agreementTemplateVariables = new Map<String,echosign_dev1.AgreementTemplateVariable>();
            for(WorkOrder__c wo : woforSign){
                if(!String.isBlank(wo.TemplateId__c) && !String.isBlank(wo.WorkOrderSignee__c)){
                    echosign_dev1.AgreementTemplateService.load(wo.TemplateId__c,wo.Id,agreementTemplateVariables);
                }
            }
        }
       
    }
}
 
When the process is done I see only one Aggreement is send for Signature as for other work order the agrrements are in draft stage , and the error on the aggerement is no file attached to send. In apex log i also see this error 
"You have uncommitted work pending. Please commit or rollback before calling out"
 
Our expectation is for each work order and agreement will be send for signature , each work order can have same template Id or can have different template id. 
This topic has been closed for replies.

1 reply

Meenakshi_Negi
Legend
December 3, 2023

Hi Abhi337095073ozj,

 

Thank you for reaching out.

 

We have checked that you are using the Adobe Sign Enterprise plan. This is something that the experts can best answer. Please contact our Adobe Sign Enterprise support team for the correct information. You may contact them using the steps in the following help document: https://helpx.adobe.com/sign/using/adobesign-support-resources.html.

 

 

Thanks,

Meenakshi