如何从Apex生成DocuSign嵌入式签名URL?

发布于 2025-02-03 01:01:13 字数 40 浏览 1 评论 0 原文

我想生成DocuSign嵌入式URL,以获取由社区用户签署的文档。

I want to generate the DocuSign embedded URL to get the documents signed by the community user.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往事随风而去 2025-02-10 01:01:13

我能够达到要求。这是

初始内容

  1. 双方(Salesforce和DocuSign本身)的DocuSign设置的
  2. 。签名用户必须分配“ docusign发件人”权限集,以签署
    文档。

创建并发送一个信封 - 第一个方法

public static String sendEnvelope(String recordId) {
  Id mySourceId = recordId; // The ID of the initiating Salesforce object
  // Create an empty envelope and add a Salesforce Document and embedded signer  
     recipient
  // The embedded signer will be the current user with sequence and routing 
     order 1 and role "Signer 1" by default
  List<dfsle.Document> myDocuments = new List<dfsle.Document>();
      // Content Version need to be param or queried 
        myDocuments = 
             dfsle.DocumentService.getDocuments(ContentVersion.getSObjectType(),
             new Set<Id> { ContentVersionId(s) });  
 dfsle.Envelope dsEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(
 new dfsle.Entity(mySourceId))//The initiating Salesforce entity current SF user 
    .withDocuments(myDocuments)
    .withRecipients(new List<dfsle.Recipient> {
    dfsle.Recipient.newEmbeddedSigner() // An embedded signer
 }
);

// Send the envelope.
dsEnvelope = dfsle.EnvelopeService.sendEnvelope(
    dsEnvelope, // The envelope to send
    true // Send now?
);
// Return string value of DocuSign envelope ID
return String.valueOf(dsEnvelope.docuSignId);

}

主机嵌入式签名会话 - 第二种方法

// passing envId as parameter that we will receive from above method
public static String getEmbeddedSigningUrl(String envId) {
    //  url will be redirect URL
    Url mySigningUrl = dfsle.SigningService.getEmbeddedSigningUrl(
                     dfsle.UUID.parse(envId), // envId value as a UUID
                     new URL(url) // url value as a URL
                   );
    // Return string value of url to controller
    return mySigningUrl.toExternalForm();

}

  1. 可变源ID - 它是父母对象记录ID我们想将签名的文档存储回Salesforce。

  2. 集合的内容版本ID存储为具有S1,D1标签等的文件

      myDocuments = 
             dfsle.documentservice.getDocuments(contentversion.getSobjectType(),    
             新套件&lt; id&gt; {contentversionId(s)});
     
  3. 重定向URL-签署了我们要重定向用户的文档后。

  4. 在社区用户中使用DocuSign的情况
    注意:在“ DocuSign设置”选项卡中,在左菜单中选择配置,然后转到“设置”选项卡,然后选择启用系统发件人旁边的用户。这使社区用户即使不是DocuSign帐户的成员,也可以发送信封。在这种情况下,信封将从您选择的管理用户发送。

要记住的重要点
如果我们想增加时间
我们将不得不与DocuSign支持团队交谈,并且可以提高最大
至15分钟,具体取决于服务计划。

参考

I am able to achieve the requirement. Here is the solution

Initial things

  1. DocuSign setup from both sides (Salesforce and DocuSign itself).
  2. Signing user must be assigned “DocuSign Sender” permission set to sign the
    document(s).

Create and send an envelope – First method

public static String sendEnvelope(String recordId) {
  Id mySourceId = recordId; // The ID of the initiating Salesforce object
  // Create an empty envelope and add a Salesforce Document and embedded signer  
     recipient
  // The embedded signer will be the current user with sequence and routing 
     order 1 and role "Signer 1" by default
  List<dfsle.Document> myDocuments = new List<dfsle.Document>();
      // Content Version need to be param or queried 
        myDocuments = 
             dfsle.DocumentService.getDocuments(ContentVersion.getSObjectType(),
             new Set<Id> { ContentVersionId(s) });  
 dfsle.Envelope dsEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(
 new dfsle.Entity(mySourceId))//The initiating Salesforce entity current SF user 
    .withDocuments(myDocuments)
    .withRecipients(new List<dfsle.Recipient> {
    dfsle.Recipient.newEmbeddedSigner() // An embedded signer
 }
);

// Send the envelope.
dsEnvelope = dfsle.EnvelopeService.sendEnvelope(
    dsEnvelope, // The envelope to send
    true // Send now?
);
// Return string value of DocuSign envelope ID
return String.valueOf(dsEnvelope.docuSignId);

}

Host an embedded signing session – second method

// passing envId as parameter that we will receive from above method
public static String getEmbeddedSigningUrl(String envId) {
    //  url will be redirect URL
    Url mySigningUrl = dfsle.SigningService.getEmbeddedSigningUrl(
                     dfsle.UUID.parse(envId), // envId value as a UUID
                     new URL(url) // url value as a URL
                   );
    // Return string value of url to controller
    return mySigningUrl.toExternalForm();

}

  1. Variable Source id – It is the parent object record id where we want to store the signed documents back into salesforce.

  2. Set of content version ids which are stored as files with s1,d1 tags etc.

    myDocuments = 
             dfsle.DocumentService.getDocuments(ContentVersion.getSObjectType(),    
             new Set<Id> { ContentVersionId(s) });
    
  3. Redirect URL - After signing the document(s) where we want to redirect the user.

  4. In the case of using DocuSign in the context of Community user
    Note: In the DocuSign Setup tab choose Configuration in the left menu, then go to the Settings tab and choose a user next to Enable System sender. This allows Community users to send envelopes even if they are not a member of the DocuSign account. In that case, envelopes will be sent from the admin user that you selected.

Important Points to remember
Embedded URL is valid only for 5 mins by default, if we want to increase the time
we will have to talk to the DocuSign support team and it can be increased max up
to 15 mins depending on the service plan.

References
https://developers.docusign.com/docs/salesforce/how-to/embedded-sending-signing/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文