简体   繁体   中英

How to send docusign draft envelope to recipient in sequence?

Here is complete flow which I am using to send draft envelope to signing handler so that signing handler can make modification before sending to other signer recipients:

//Get Access Token:

private void GetAccessToken()
 {
    var apiClient = new ApiClient();
    string ik = integrationKey;
    string userId = userId;
    string authServer = authServer;
    string fileContents = await FileHelper.ReadFileContentAsString(RSAKeyPemFile);

    //Request for access token
    OAuth.OAuthToken authToken = apiClient.RequestJWTUserToken(ik,
                    userId,
                    authServer,
                    Encoding.UTF8.GetBytes(fileContents),
                    1);


    //Get userinfo for AccountId and BaseURI
    string accessToken = authToken.access_token;
    apiClient.SetOAuthBasePath(authServer);
    OAuth.UserInfo userInfo = apiClient.GetUserInfo(authToken.access_token);
    Account acct = null;

    var accounts = userInfo.Accounts;
    {
        acct = accounts.FirstOrDefault(a => a.IsDefault == "true");
    }
    string accountId = acct.AccountId;
    string baseUri = acct.BaseUri + "/restapi";

    //Set details to configuration object which would be used for sending envelope request
    this.accessToken = accessToken;
    this.accountId = accountId;
    this.baseUri = baseUri;
}

//Create envelope

private EnvelopeDefinition MakeEnvelope()
{

    // create the envelope definition
    EnvelopeDefinition env = new EnvelopeDefinition();
    env.EmailSubject = "Please sign this document";

    //Get document extension
    Document documentToSign = new Document
    {
        DocumentBase64 = Convert.ToBase64String(documentBytes),
        Name = documentName,
        FileExtension = documentExtension,
        DocumentId = documentId
    };

    // The order in the docs array determines the order in the envelope
    env.Documents = new List<Document> { documentToSign };

    var routingOrder = 1;
    var signatureHandler = new Editor
    {
        Email = signatureHandler.mail,
        Name = signatureHandler.displayName,
        RecipientId = routingOrder.ToString(),
        RoutingOrder = routingOrder.ToString()
    };

    routingOrder++;

    List<Signer> signers = new List<Signer>();
    foreach (var signer in signerList)
    {
        signers.Add(new Signer { Name = signerList.displayName, Email = signerList.mail, RoleName = signerList.jobTitle, RecipientId = routingOrder.ToString(), RoutingOrder = routingOrder.ToString() });
        routingOrder++;
    }

    // Add the recipients to the envelope object
    Recipients recipients = new Recipients
    {
        Editors = new List<Editor> { signatureHandler },
        Signers = signers
    };

    //Attache all recipients to envelope
    env.Recipients = recipients;

    env.EventNotification = eventNotification;

    env.Status = "created";

    return env;
}

//Send draft envelope

public void SendEnvelope()
{
    EnvelopeDefinition env = MakeEnvelope();
    var config = new Configuration(baseUri);

    var apiClient = new ApiClient(baseUri);
    apiClient.Configuration = config;
            
    EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
    EnvelopeSummary result = await envelopesApi.CreateEnvelopeAsync(accountId, env);
}

But each time the draft envelope in going under admin account draft rather signing handler(which is in this case editor). I am doing something wrong?

You want an editor recipient to manage some of the later recipients. That's fine.

But the editor won't receive the envelope until it is in sent status. You currently are holding the envelope in created status which is draft.

Try changing

env.Status = "created";

to

env.Status = "sent";

Added

Regarding

but still editor is not able to do changes to envelope request. It says not have sufficient permission to do changes even though he has DS Admin profile permission. What I am trying to do is, envelope should go to editor's draft (should able to do modification) and should be able to do modification.

Unfortunately I don't have any experience with the editor recipient type. (And it is not clear to me what you mean by "modify" the envelope--change the documents? Change the other recipients? Something else?

Check that the editor is using the exact same name and email address that they use to login to DocuSign.

More importantly:

Try out your workflow using just the DocuSign web app (no API). Check that after the envelope is sent, the editor can do what you want.

Then use API logging to see exactly how the DocuSign web app is setting the editor recipient's attributes. You can then duplicate that in your API application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM