Skip to main content
Participant
October 18, 2021
Answered

Send agreements via Apex code (Salesforce integration) - Invalid or no file info is provided

  • October 18, 2021
  • 3 replies
  • 4808 views

Sample Code - 

//Inserting the Agreement

echosign_dev1__SIGN_Agreement__c a = new echosign_dev1__SIGN_Agreement__c ();
a.Name = 'Test agreement 6'+system.now();
a.echosign_dev1__Message__c = 'ABCD';
a.echosign_dev1__Recipient__c = '0030o00003ZwbtnAAB';
a.echosign_dev1__SignatureOrder__c = 'Recipient signs, then I sign';
a.echosign_dev1__SignatureType__c = 'e-Signature';
a.echosign_dev1__Signature_Flow__c = 'Order Entered';
a.echosign_dev1__SenderSigns__c = true;
a.echosign_dev1__Recipient_Addresses__c = 'xxxxxxxxxxxxxxxxx@gmail.com,';

insert a;

 

/*Taking file from an Agreement which sent the e-mail successfully to recipients, and creating a new content document link to the agreement (I am able to see the file in the Agreement record, when I navigate to it on the UI) */
ContentDocumentLink cd = new ContentDocumentLink();
cd.LinkedEntityId = a.Id;
cd.ContentDocumentId = '0690o00000ObZAcAAN';
cd.visibility = 'AllUsers';
insert cd;

 

//Inserting the recipients

Echosign_Dev1__SIGN_Recipients__c asdasd = new Echosign_Dev1__SIGN_Recipients__c();
asdasd.echosign_dev1__Agreement__c = a.Id;
asdasd.echosign_dev1__Contact__c = '0030o00003ZwbtnAAB';
asdasd.echosign_dev1__Recipient_Role__c = 'Signer';
asdasd.echosign_dev1__Recipient_Type__c = 'Contact';
asdasd.echosign_dev1__Order_Number__c = 1;

insert asdasd;

 

//And as a last step I am calling the "echosign_dev1.EchoSignApiService.SendDocumentResult" method and passing the agreement Id as the parameter. 

 

But I am getting the error - 

But I am getting the error - 'Invalid or no file info is provided.'  on the field - echosign_dev1__ErrorMessage__c on Agreement object.

 

Can you please help with the same/or let me know if I'm missing something?

This topic has been closed for replies.
Correct answer SimonESATS

you want to make use of the agreement template service to create agreements using the agreement template record.

See 

https://helpx.adobe.com/sign/using/salesforce-integration-developer-guide.html

and for a primer on using the template rcord see

https://community.adobe.com/t5/adobe-sign-discussions/sending-adobe-sign-agreements-from-custom-objects-in-salesforce/m-p/5885031

3 replies

Flowace
Participant
April 8, 2024

Your code seems to be missing a crucial step: telling Adobe eSign what document to send with the agreement. The error message "Invalid or no file info is provided" indicates this.

Here's the likely culprit:

  • Missing Attachment: While you link a document using ContentDocumentLink, Adobe eSign might require the document to be directly attached to the agreement record itself.

Solution:

Explore Salesforce Apex methods for attaching files to records (e.g., Attachment API). Attach the document to the agreement record before attempting to send it with Adobe eSign.


Here's how you can potentially modify your code to address these issues:

//Inserting the Agreement
echosign_dev1__SIGN_Agreement__c a = new echosign_dev1__SIGN_Agreement__c ();
a.Name = 'Test agreement 6'+system.now();
a.echosign_dev1__Message__c = 'ABCD';
a.echosign_dev1__Recipient__c = '0030o00003ZwbtnAAB';
a.echosign_dev1__SignatureOrder__c = 'Recipient signs, then I sign';
a.echosign_dev1__SignatureType__c = 'e-Signature';
a.echosign_dev1__Signature_Flow__c = 'Order Entered';
a.echosign_dev1__SenderSigns__c = true;
a.echosign_dev1__Recipient_Addresses__c = 'xxxxxxxxxxxxxxxxx@gmail.com,';

insert a;

// Link the Agreement to the ContentDocument (assuming you have a method to get the correct ID)
ContentDocumentLink cd = linkAgreementToDocument(a.Id);

if (cd == null || cd.Id == null) {
// Handle error - ContentDocumentLink failed
System.debug('Error linking ContentDocument to Agreement: ');
return; // Or throw an exception
}

// Now that the link is established, proceed with recipient insertion etc.

/*Taking file from an Agreement which sent the e-mail successfully to recipients, and creating a new content document link to the agreement (I am able to see the file in the Agreement record, when I navigate to it on the UI) */
// (Rest of your code remains the same)

 

Participant
January 14, 2022

Hello, did you manage to get your code working? I'm having the same issue and my code is very similiar to yours.

Participant
January 15, 2022

Like mentioned in the previous comment. Started using agreement templates. Let me know if you need more insights to what I've tried to implement.

Participant
January 17, 2022

Hi, thanks for your message. 

Yes, I'd like help using templates. I just need to automatically send a PDF linked to an opportunity to sign. Why do I need a template?

SimonESATSCorrect answer
Adobe Employee
October 18, 2021

you want to make use of the agreement template service to create agreements using the agreement template record.

See 

https://helpx.adobe.com/sign/using/salesforce-integration-developer-guide.html

and for a primer on using the template rcord see

https://community.adobe.com/t5/adobe-sign-discussions/sending-adobe-sign-agreements-from-custom-objects-in-salesforce/m-p/5885031