david.walker | Posts: 33

Retrieving approvals

0 votes

I'm not having any luck with the code below to retrieve approvals. It's not outputting anything. Any ideas why?

 

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OneSpanSign.Sdk;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json.Linq;
using Microsoft.SharePoint.Client;
using System.Security;

public class retrieveFieldValues
{

    private static string API_KEY = "";
    private static string API_URL = "https://signer-gov.esignlive.com/api";

    public static void Main(string[] args)
    {
        OssClient client = new OssClient(API_KEY, API_URL);

        string signer1Id = "Prime_Signer";
        string signer2Id = "DBE_EDGE_Signer";
        string documentId = "doc1";

        PackageId packageId = new PackageId("ozwvKtWtM-1XlxEzDxOC7cnAuSM=");
        DocumentPackage sentPackage = client.GetPackage(packageId);

        int i = 1;
        foreach (Signature signature in signer1SignableSignatures)
        {
            Debug.WriteLine("Position of signature " + i + ": (" + signature.X + ", " + signature.Y + ") on page " + signature.Page);
            i++;
        }
        foreach (Signature signature in signer2SignableSignatures)
        {
            Debug.WriteLine("Position of signature " + i + ": (" + signature.X + ", " + signature.Y + ") on page " + signature.Page);
            i++;
        }
    }
}


Approved Answer
Duo_Liang | Posts: 3776

Reply to: Retrieving approvals

0 votes

Thanks for the information! I think I figured it out - Because the transaction was created from a fast track link (vs created from code), therefore the Signer ID was randomly generated and wasn't identical to "Prime_Signer" and "DBE_EDGE_Signer".

-If you are not using fast track in real practice, the above code should work for transactions created by .NET SDK code

-If using fast track link is part of your use case, instead of using "ossClient.ApprovalService.GetAllSignableSignatures()" function, you can use custom logic and get all signable signatures, similar to below code:

 

        public static void Main(string[] args)
        {
            OssClient ossClient = new OssClient("your_api_key", "https://sandbox.esignlive.com/api");

            string signer1Id = "Prime_Signer";
            string signer2Id = "DBE_EDGE_Signer";
            string documentId = "doc1";

            PackageId packageId = new PackageId("Pm6qdZkWZkmUTp01CSEYchuK8U0=");
            DocumentPackage sentPackage = ossClient.GetPackage(packageId);


            Dictionary<string, string> signerEmail = new Dictionary<string, string>();

            foreach (Signer signer in sentPackage.Signers)
            {
                if (signer.Id == signer1Id || signer.Id == signer2Id)
                {
                    signerEmail.Add(signer.Id,signer.Email);
                }
            }


            int i = 1;
            foreach (Document document in sentPackage.Documents)
            {
                if (document.Id == documentId) {
                    foreach (Signature signature in document.Signatures)
                    {
                        if (signerEmail.ContainsValue(signature.SignerEmail)) {
                            Debug.WriteLine("Position of signature " + i + ": (" + signature.X + ", " + signature.Y + ") on page " + signature.Page);
                            i++;
                        }
                    }
                }
            }

        }

 

Duo


Duo_Liang | Posts: 3776

Reply to: Retrieving approvals

0 votes

Hi David,

 

Are you using function ossClient.ApprovalService.GetAllSignableSignatures()? Below code seems working for me:

            OssClient ossClient = new OssClient("api_key", "https://sandbox.esignlive.com/api");

            string signer1Id = "Prime_Signer";
            string signer2Id = "DBE_EDGE_Signer";
            string documentId = "25fbcc3401fea995fff5fc8528334a28c14c20eff4ee95c8";

            PackageId packageId = new PackageId("ArQPT29WdumSrAso7d8hfubxpm0=");
            DocumentPackage sentPackage = ossClient.GetPackage(packageId);

            IList<Signature> signer1SignableSignatures = ossClient.ApprovalService.GetAllSignableSignatures(sentPackage, documentId, signer1Id);
            int i = 1;
            foreach (Signature signature in signer1SignableSignatures)
            {
                Debug.WriteLine("Position of signature " + i + ": (" + signature.X + ", " + signature.Y + ") on page " + signature.Page);
                i++;
            }

            IList<Signature> signer2SignableSignatures = ossClient.ApprovalService.GetAllSignableSignatures(sentPackage, documentId, signer2Id);
            foreach (Signature signature in signer2SignableSignatures)
            {
                Debug.WriteLine("Position of signature " + i + ": (" + signature.X + ", " + signature.Y + ") on page " + signature.Page);
                i++;
            }

 

Duo


david.walker | Posts: 33

Reply to: Retrieving approvals

0 votes

Yes, I am. Apparently I didn't copy the entire code into my previous post.

 

        OssClient ossClient = new OssClient(API_KEY, API_URL);

        string signer1Id = "Prime_Signer";
        string signer2Id = "DBE_EDGE_Signer";
        string documentId = "doc1";

        PackageId packageId = new PackageId("ozwvKtWtM-1XlxEzDxOC7cnAuSM=");
        DocumentPackage sentPackage = ossClient.GetPackage(packageId);

        IList<Signature> signer1SignableSignatures = ossClient.ApprovalService.GetAllSignableSignatures(sentPackage, documentId, signer1Id);
        IList<Signature> signer2SignableSignatures = ossClient.ApprovalService.GetAllSignableSignatures(sentPackage, documentId, signer2Id);

        int i = 1;
        foreach (Signature signature in signer1SignableSignatures)
        {
            Debug.WriteLine("Position of signature " + i + ": (" + signature.X + ", " + signature.Y + ") on page " + signature.Page);
            i++;
        }
        foreach (Signature signature in signer2SignableSignatures)
        {
            Debug.WriteLine("Position of signature " + i + ": (" + signature.X + ", " + signature.Y + ") on page " + signature.Page);
            i++;
        }

 

But it's not outputting anything. Does it work for click-to-sign signatures?


david.walker | Posts: 33

Reply to: Retrieving approvals

0 votes

Thank you!


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off