3

I would like to prefill a few fields on a Template document used with embedded signing. I am using c#. I added data fields through the DocuSign template wizard and would like to know how I can prefill a data field from my embedded signing code in c-sharp? In my case, I added a Date Of Birth and Telephone Data field to the template and want to pass values in my XML when pulling the document up for signing. Here is what I have:

 string requestBody = "<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" +
            "<accountId>" + accountId + "</accountId>" +
            "<status>sent</status>" +
            "<emailSubject>Electronic Release of Information</emailSubject>" +
            "<emailBlurb>Please sign the release of information form</emailBlurb>" +
            "<templateId>" + System.Configuration.ConfigurationManager.AppSettings.Get("DocusignTempId") + "</templateId>" +
            "<templateRoles>" +
            "<templateRole>" +
            "<email>" + pUserEmail + "</email>" +   // NOTE: Use different email address if username provided in non-email format!
            "<name>" + pUserName + "</name>" + // username can be in email format or an actual ID string
            "<tabs>" +
            "<textTabs>" +
            "<textTab>" +
            "<tabLabel>DOB</tabLabel>" + 
            "<value>" + pDOB + "</value>" +
            "</textTab>" +
             "<textTab>" +
            "<tabLabel>Telephone</tabLabel>" +
            "<value>" + pTelephone + "</value>" +
            "</textTab>" +
            "</textTabs>" +
            "</tabs>" +
            "<roleName>Signer</roleName>" +
            "<clientUserId>1</clientUserId>" +
            "</templateRole>" +
            "</templateRoles>" +
            "</envelopeDefinition>";

On the demo site I created 2 Data Fields on my template: Data Field : Label: DOB, Data Field: Label: Telephone

Need to know what I am doing wrong. The Signing portion and everything else is working fine.

newm0528
  • 97
  • 1
  • 8
  • [Duplicate question](http://stackoverflow.com/questions/17418066/how-do-i-pre-populate-the-values-of-docusign-tabs) This has already been answered- in your request body you populate the tabs by specifying the same ***tabLabel*** that you set in your template and set its value through the ***value*** property – Ergin Jul 19 '13 at 06:14

2 Answers2

0

Down voted due to duplicate question, but this is how you would do it:

"tabs": {
    "textTabs": [
    {
        "tabLabel": "Data Field 1",
        "value": "Initial data goes here...",
        "xPosition": "200",
        "yPosition": "200",
        "documentId": "1",
        "pageNumber": "1"
    }]
}
Ergin
  • 9,254
  • 1
  • 19
  • 28
  • This was not completely answered. I am using the C# code with XML. Where can I put this in the XML format? – newm0528 Jul 19 '13 at 13:47
  • What do you mean by "where can you put the xml"? It goes in the body of your request. Please research before you ask these questions, all of this is easily answered if you review the [DocuSign Dev Center](http://www.docusign.com/developer-center). If you go through there you'll find the API Walkthroughs, which have exactly what you are looking for (i.e. an embedded signing example in C# that uses an XML request body instead of JSON – Ergin Jul 19 '13 at 17:50
  • 2
    Modified my question. Not everything is answered in your developer site. Your API walkthrough does not contain prefilling answers. I found an old post that helped, but it is not working. – newm0528 Jul 19 '13 at 20:49
0

I have some code that does that, but it's using JSON (not XML). Here it is:

        //
        // DocuSign Step 1. Login
        //
        , function(next) {
            var options = {
                "method": "GET"
                , "headers": {
                    "X-DocuSign-Authentication": dsAuthHeader
                    , "content-type": "application/json"
                    , "accept": "application/json"
                }
                , "uri": "https://demo.docusign.net/restapi/v2/login_information"
            };

            request(options, function(err, res, body) {
                console.log("Login Result: \r\n", JSON.parse(body))
                baseUrl = JSON.parse(body).loginAccounts[0].baseUrl;

                next(null);
            });

        }

        //
        // DocuSign Step 2. Request Signature From Template
        //
        , function(next) {
        var uri  = baseUrl + "/envelopes"
            , options = {
                "method": "POST"
                , "headers": {
                    "X-DocuSign-Authentication": dsAuthHeader
                    , "content-type": "application/json"
                    , "accept": "application/json"
                }
                , "uri": uri
                , "body" : JSON.stringify({
                    "emailSubject": "Patient Intake form from Human API"
                    , "templateId": templateId
                    , "templateRoles": [{
                        "email": humanEmail
                        , "name": humanName
                        , "roleName": templateRoleName
                        , "clientUserId": 1
                        , "tabs" : {
                            "textTabs" : [{
                                 tabLabel : "Email Address",
                                 value : humanEmail
                                }
                                , {
                                    tabLabel : "Name",
                                    value : humanName
                                }
                                , {
                                    tabLabel : "Height",
                                    value : height
                                }
                                , {
                                    tabLabel : "Weight",
                                    value : weight
                                }
                                ,{
                                    tabLabel : "Address 1",
                                    value : '1212 Victoria Lane'
                                }
                                ,{
                                    tabLabel : "Address 2",
                                    value : 'San Francisco, CA, 94109'
                                }

                            ]
                        }
                    }]
                    ,"status": "sent"
                })
            };

        request(options, function(err, res, body) {
            console.log("Request Envelope Result: \r\n", JSON.parse(body));
            next(null, body);
        })
    }

        //
        // DocuSign Step 3. Get Send View
        //
        , function(body, next) {
        var envelopeUri = JSON.parse(body).uri
            , options = {
                "method": "POST"
                , "headers": {
                    "X-DocuSign-Authentication": dsAuthHeader
                    , "content-type": "application/json"
                    , "accept": "application/json"
                }
                , "uri": baseUrl + envelopeUri + "/views/recipient"
                , "body": JSON.stringify({
                    "authenticationMethod": "email",
                    "email": humanEmail,
                    "returnUrl": "http://humanapi.co/",
                    "userName": humanName,
                    "clientUserId": "1"
                })
            };

        request(options, function(err, res, body) {
            console.log("Get Embedded View: \r\n", JSON.parse(body));
            response.render('docusign', { signing_url: JSON.parse(body).url });
        });
    }

I know this is not exactly what you are looking for (C# + XML) but maybe you can grab this JSON and just put it in C# requests? Let me know.

mikebz
  • 3,277
  • 8
  • 37
  • 50
  • Thank you. I think I have the code correct now based on my above XML, but it still is not prefilling. I am guessing it may have something to do with my template and the data fields I am creating. I am goign to see if I can find any more documentation on the template creation process and creating data fields. Thank you again. – newm0528 Jul 22 '13 at 12:32
  • I have found a another post around the same time with what sounds like the same issue possibly at http://stackoverflow.com/questions/17600349/how-to-pre-fill-tabs-on-a-server-template-with-the-docusign-api. I have tried to modify the template fields to prefill, but no matter what I try, these fields are not prefilling. The signing and everything else works great. I don't know if there is anyway you can look at my template on the demo site. If there is, it might help. – newm0528 Jul 22 '13 at 13:13
  • 1
    Yes, I finally got this working with c# and JSON. Mike, thank you for your help. Unless I have syntax wrong above, it would appear that C# and XML are not the right way to go. Would it be possible to add that to your embedded signing walkthrough? Also, the clietUserID in the walkthrough needs to be in the envelope definition to work and it is not in that example. Thanks again. – newm0528 Jul 24 '13 at 13:54