如何从 docusign 信封中检索模板 ID

How can I retrieve template id from docusign envelope

我已经从模板创建了一个 DocuSign 信封。我已经存储了 信封 ID 以备将来操作。使用此 envelope id 我只能检索我创建的信封,但我也需要 template id。有什么方法可以从信封或 FolderItems 中检索 模板 ID?请帮助:(

如果 templateId 作为元数据保存在信封中的任何位置(我不相信是这样),我不确定您是否从模板创建了信封。因此,您可以简单地自己做 - 尝试使用 Envelope Custom Fields 在创建时存储 templateId,然后 templateId 将存储为在信封的整个生命周期中的元数据。

在 DocuSign API 文档中搜索以了解有关 "Envelope Custom Fields" 的更多信息。例如,here 是关于如何创建它们的页面。

谢谢@Ergin。我已经尝试实现您的想法并且它正在工作。但是无论我做了什么,还有一些其他问题。我正在分享我的部分代码。

//Getting available folder list of my DocuSign account.
DocuSignServiceRef.AvailableFolders folders = DocuSignHelper.GetDocuSignServiceClient().GetFolderList(new DocuSignServiceRef.FoldersFilter { AccountId = DocuSignHelper.UserID });

//Creating a FolderFilter item to get folder items using this filter.
DocuSignServiceRef.FolderFilter filter = new DocuSignServiceRef.FolderFilter();
filter.AccountId = DocuSignHelper.UserID;
filter.FolderTypeInfo = new DocuSignServiceRef.FolderTypeInfo();
filter.FolderTypeInfo = folders.Folders[1].FolderTypeInfo; //Filter Send Items

//Getting sent items
DocuSignServiceRef.FolderResults results = DocuSignHelper.GetDocuSignServiceClient().GetFolderItems(filter);

if (results != null && results.ResultSetSize > 0)
{
    foreach (DocuSignServiceRef.FolderItem item in results.FolderItems)
    {
        foreach (DocuSignServiceRef.RecipientStatus recipient in item.RecipientStatuses)
        {
            //Filtering items by Recipient
            if (recipient.Email.Equals(RecipientEmail))
            {   
                //Getting envelope of the folder item
                DocuSignServiceRef.Envelope sentEnvelope = DocuSignHelper.GetDocuSignServiceClient().RequestEnvelope(item.EnvelopeId, false);
                if (sentEnvelope.CustomFields != null)
                {
                    //Checking envelope's custom fields for template id
                    foreach (DocuSignServiceRef.CustomField customField in sentEnvelope.CustomFields)
                    {
                        if (string.Equals(customField.Name, "TemplateID"))
                        {
                            if (customField.Value == "{CurrentTemplateID}")
                            {
                                HasAlreadySignedSameTemplate = true;
                                //I will not request the recipient for another signature on same template.
                            }
                        }
                    }
                }
            }
        }
    }
}

上面的代码对我有用。但是加载所有已发送的项目花费了太多时间。我看不到任何在 FolderFilter 中设置收件人信息的方法。如果我可以在加载已发送邮件时首先在过滤器中设置收件人的电子邮件,那么将为我节省时间。否则此代码将无法使用。

您对修改我的实现有任何想法吗?

如果您使用 REST 调用创建信封,您可以通过调用 templatesv2/accounts/:accountId/envelopes/:envelopeId/templates 检索信息 试一试in the envelope tab。我注意到使用 SOAP sdk 创建的信封没有填写此信息。