【发布时间】:2017-05-05 15:06:55
【问题描述】:
问题:
如何将user_id 之类的自定义属性添加到DocuSign 信封,以便在收到DocuSign 的回调时,可以检索关联的user_id? (在 VB.Net 中)
我已阅读有关 Custom Fields 的文档,尽管这似乎是我会在管理面板中的模板上创建它们 - 如果可能的话,我宁愿在代码中动态创建它们。尽管如此,我还是尝试使用这种方法(不成功)。代码如下。
我的尝试
手动设置 EnvelopeID:
envDef.EnvelopeId = app_Id
EnvelopID 被 DocuSign 自动生成的 GUID 覆盖
创建自定义字段:
(在管理面板中创建一个名为 User_ID 的 Text CustomField 后...)
Dim user_id_field As New TextCustomField()
user_id_field.Name = "User_ID"
user_id_field.Value = user_id
Dim custom_fields As New CustomFields()
custom_fields.TextCustomFields.Add(user_id_field)
envDef.CustomFields = custom_fields
DocuSign XML 有效负载中完全没有自定义字段
最后的手段:
我可以创建一个关联表,在创建信封时将 DocuSign 的 EnvelopeID GUID 与 user_id 关联起来。然后我可以使用EnvelopeID 在回调中查找user_id。
我的代码:
下面的代码运行良好。用户收到文档并对其进行签名,然后我们会在文档发送和文档完成时收到回调。当然,缺少的部分是传递 DocuSign 我的自定义属性。
(为简洁起见,我排除了很多信息,如角色、模板等。)
Dim envDef As New EnvelopeDefinition()
Dim envelope_events As New List(Of EnvelopeEvent)
envelope_events.Add(New EnvelopeEvent("sent", True))
envelope_events.Add(New EnvelopeEvent("completed", True))
Dim recipient_events As New List(Of RecipientEvent)
recipient_events.Add(New RecipientEvent(True, "Sent"))
recipient_events.Add(New RecipientEvent(True, "Completed"))
recipient_events.Add(New RecipientEvent(True, "AuthenticationFailed"))
Dim notification As New EventNotification
' -- Notification properties excluded for brevity --
notification.EnvelopeEvents = envelope_events
notification.RecipientEvents = recipient_events
envDef.EventNotification = notification
Dim apiClient As New ApiClient("https://demo.docusign.net/restapi")
Dim cfi As New Configuration(apiClient)
Dim authHeader As String = "{""Username"":""" + userName + """, ""Password"":""" + password + """, ""IntegratorKey"":""" + INTEGRATOR_KEY + """}"
cfi.AddDefaultHeader("X-DocuSign-Authentication", authHeader)
Dim envelopesApi As New EnvelopesApi(cfi)
Dim envelopeSummary As EnvelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef)
【问题讨论】:
标签: vb.net controller docusignapi