Copy Templates and Layouts between Users in .NET

0 votes

I know there is a tool to copy templates and layouts between users.  I want to add that ability to my own tool we have for our help desk.  Is there an example of how to do this in .NET that already exists? (we would download it form one user and upload it to another user's account using the API keys)


Richard DeMello

Approved Answer

Reply to: Copy Templates and Layouts between Users in .NET

0 votes

Hi Richard,


Below is a code snippet I created to copy templates between users. Because the time is limited, the code utlizes the .NET SDK, and somehow it can't copy field conditions due to the nature of the SDK designs. Next, it could take me some time to translate the code to RESTful fashion.


            OssClient ossClient1 = new OssClient("QVRxx4TA==", "");
            OssClient ossClient2 = new OssClient("Z0JXxxxNRNQ==", "");
            String template_from_id = "z2crzSkaEBgy81qCyifpRytmBJQ=";
            String template_to_sender_id = "gBWRANNzRIoR";

            //Step1: copy template
            DocumentPackage template_from = ossClient1.GetPackage(new PackageId(template_from_id));
            //download documents
            foreach (var doc in template_from.Documents) {
                doc.Content = ossClient1.DownloadOriginalDocument(template_from.Id, doc.Id);
                doc.FileName = doc.Name + ".pdf";

            //Step2: replace sender
            Signer sender = null;
            foreach (var signer in template_from.Signers)
                if (signer.SignerType == "ACCOUNT_SENDER")
                    sender = signer;
            if (sender != null)
                template_from.SenderInfo = null;

                Sender to_sender = ossClient2.AccountService.GetSender(template_to_sender_id);
                template_from.SenderInfo = SenderInfoBuilder.NewSenderInfo(to_sender.Email).Build();

                foreach (var doc in template_from.Documents)
                    foreach (var signature in doc.Signatures.ToArray())
                        if (signature.SignerEmail == sender.Email)

                            Signature signature_to = new Signature(to_sender.Email,signature.Page,signature.X,signature.Y);
                            signature_to.Disabled = signature.Disabled;
                            signature_to.EnforceCaptureSignature = signature.EnforceCaptureSignature;
                            signature_to.Extract = signature.Extract;
                            signature_to.FontSize = signature.FontSize;
                            signature_to.Height = signature.Height;
                            signature_to.Width = signature.Width;
                            signature_to.Id = signature.Id;
                            signature_to.Name = signature.Name;
                            signature_to.Optional = signature.Optional;
                            signature_to.Style = signature.Style;

            template_from.Id = null;
            template_from.Conditions = new List<FieldCondition>();

            PackageId template_to_id = ossClient2.CreateTemplate(template_from);
            Debug.WriteLine($"template_to_id: {template_to_id.Id}");

            //Step3: copy reminder
            ReminderSchedule reminderSchedule_from = ossClient1.ReminderService.GetReminderScheduleForPackage(new PackageId(template_from_id));
            if (reminderSchedule_from != null) {
                reminderSchedule_from.PackageId = template_to_id;

            //Step4: copy document visiblity
            DocumentVisibility documentVisiblity_from = ossClient1.getDocumentVisibility(new PackageId(template_from_id));
            if (documentVisiblity_from != null) {
                ossClient2.ConfigureDocumentVisibility(template_to_id, documentVisiblity_from);


Duo Liang OneSpan Evangelism and Partner Integrations Developer

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