david.walker | Posts: 33

Math in a template

0 votes

Hi,

At OneSpan Sign Template Fields | OneSpan Community Platform there is a list of fields in the New Account SignupTemplate, one of which is {name:"driversAge", with a value of 

value:Math.abs((new Date(Date.now() - (new Date($("#inputDateOfBirth").val()).getTime()))).getUTCFullYear() - 1970)},

How can I replicate this field on my own templates using the .NET SDK?

 


Duo_Liang | Posts: 3776

Reply to: Math in a template

0 votes

Hi David,

 

Please kindly be aware that this guide is only applicable for the MyBank Demo site, where it uses a web form to collect the DOB before creating the transaction. If you are looking for a calculated field with formula, it's temporary not available, and we can definitely raise it as an Enhancement Request for future product enhancement.

 

Duo


david.walker | Posts: 33

Reply to: Math in a template

0 votes

Duo, this would really be a valuable enhancement and I would love to see this added to the product. For the short term, do you know of any other workarounds?


Duo_Liang | Posts: 3776

Reply to: Math in a template

0 votes

Hi David,

 

As a workaround, you can use date picker field to allow user to enter DOB, and a text field with numeric validation for the age, please see below .NET SDK code:

            OssClient ossClient = new OssClient(apiKey, apiUrl);
            DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed("Test Package .NET")
                    .WithSigner(SignerBuilder.NewSignerWithEmail("[email protected]")
                                    .WithFirstName("Signer First Name")
                                    .WithLastName("Signer Last Name")
                                    .WithCustomId("Signer"))
                    .WithDocument(DocumentBuilder.NewDocumentNamed("sampleAgreement")
                                    .FromFile("your_file_path")
                                    .WithSignature(SignatureBuilder.SignatureFor("[email protected]")
                                                        .OnPage(0).AtPosition(175, 165).WithSize(150,50)
                                        .WithField(FieldBuilder.Datepicker().WithId("DOB")
                                                .OnPage(0).AtPosition(175, 265).WithSize(150, 50)
                                                .WithValidation(FieldValidatorBuilder.DatepickerFormat("YYYY-MM-dd").Required().WithErrorMessage("Please select your date of birth!")))
                                        .WithField(FieldBuilder.TextField().WithId("Age")
                                                .OnPage(0).AtPosition(175, 365).WithSize(150, 50)
                                                .WithValidation(FieldValidatorBuilder.Numeric().Required().WithErrorMessage("Please enter your age!")))
                                        ))

                    .Build();

            PackageId packageId = ossClient.CreatePackageOneStep(superDuperPackage);
            ossClient.SendPackage(packageId);

 

Duo


david.walker | Posts: 33

Reply to: Math in a template

0 votes

Thanks but I was thinking more along the lines of replicating what was done for the MyBank Demo site? What would I need to do to create a similar setup?


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