rtbike | Posts: 38

Building Package with Multiple Signers Dynamically

0 votes
Hello, It seems the Package Object is not too happy with if statements with in the code block. I have up to 5 potential signers, the first signer may be one of two people. So how would I do something like this as I build the package?
         .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings())
                        
                        // From info
                        .WithSenderInfo( SenderInfoBuilder.NewSenderInfo(senderEmail)
                        .WithName( senderFirstName, senderLastName )
                        .WithTitle( senderTitle )
                        .WithCompany( senderCompany ))
                   
                    .WithSigner(SignerBuilder.NewSignerWithEmail("email")
                                      .WithFirstName("firstName")
                                      .WithLastName("lastname")
                                      .SigningOrder(1))

                if(Agent != null) {
                    .WithSigner(SignerBuilder.NewSignerWithEmail("[email protected]")
                                        .WithFirstName("AgentFirstName")
                                        .WithLastName("AgentLastName")
                                        .SigningOrder(2))
                 }

harishaidary | Posts: 1812

Reply to: Building Package with Multiple Signers Dynamically

0 votes
Hi rtbike, In order to add signer based on conditions, you'll need to create Signer objects first. Then, once you've figured out how many signers you want, you can create your document package object and send the request to eSignLive using the client. Here's a an example:
EslClient eslClient = new EslClient(Properties.Settings.Default.key, Properties.Settings.Default.url);

            PackageBuilder packBuilder = PackageBuilder.NewPackageNamed("some name!");

            if (true) {
                Signer signer = SignerBuilder.NewSignerWithEmail("[email protected]")
                        .WithFirstName("AgentFirstName")
                        .WithLastName("AgentLastName")
                        .SigningOrder(2)
                        .Build();
                packBuilder.WithSigner(signer);
           }
            DocumentPackage pack = packBuilder.Build();
            PackageId packageId = eslClient.CreatePackage(pack);
Hope this helps.

rtbike | Posts: 38

Reply to: Building Package with Multiple Signers Dynamically

0 votes
I am a little confused on how to create the package object. currently I have working demo that creates a DocumentPackage like this
DocumentPackage thisPackage = PackageBuilder
Next I need to the add the signer fields dynamically based on how many Singer objects I have? this form will also have about 110 fields injected. So I am trying to get these objects and the order I create and extend them straight
    .WithDocument(DocumentBuilder.NewDocumentNamed("MentalHealthCareDeclaration_" + CurrentUser().CurrentUserFirstName + "_" + CurrentUser().CurrentUserLastName + "_" + formNameDate)
                        .EnableExtraction()
                        .FromStream(fs, DocumentType.PDF)

                        .WithSignature(SignatureBuilder.SignatureFor(Signer.Email)
                        .WithName("V_txtMySignature")
                        .WithPositionExtracted())

                       // How do you make this also dynamic?
                        .WithSignature(SignatureBuilder.SignatureFor(Agent.Email)
                        .WithName("IIIA_txtAgentSignature")
                        .WithPositionExtracted())

harishaidary | Posts: 1812

Reply to: Building Package with Multiple Signers Dynamically

0 votes
Obviously, you can't have expressions inside an object definition. That being said, the way to go about it is to use the different builders available to you to create your Signer, Signature, Document. etc.. objects before creating your DocumentPackage object. Here's an example that should clear things up:
PackageBuilder packBuilder = PackageBuilder.NewPackageNamed("Example Package"); //create an empty PackageBuilder object. Notice that my DocumentPackage object isn't built yet. 

            //Build your signers 
            Signer signer1 = SignerBuilder.NewSignerWithEmail("first.signer")
                        .WithFirstName("AgentFirstName")
                        .WithLastName("AgentLastName")
                        .SigningOrder(1)
                        .Build();

            Signer signer2 = SignerBuilder.NewSignerWithEmail("second.signer")
                        .WithFirstName("AgentFirstName")
                        .WithLastName("AgentLastName")
                        .SigningOrder(2)
                        .Build();

            Signer signer3 = SignerBuilder.NewSignerWithEmail("third.signer")
                        .WithFirstName("AgentFirstName")
                        .WithLastName("AgentLastName")
                        .SigningOrder(3)
                        .Build();

            //add your signers depending if the condition statements are met
            if (true) {
                packBuilder.WithSigner(signer1);
            }

            if (true)
            {
                packBuilder.WithSigner(signer2);
            }

            if (true)
            {
                packBuilder.WithSigner(signer3);
            }


            //Build your DocumentBuilder object.
            DocumentBuilder doc = DocumentBuilder.NewDocumentNamed("some document")
                .FromFile("doc_file_path");

            //Build your signatures
            Signature sig1 = SignatureBuilder.SignatureFor("first.signer")
                        .WithName("IIIA_txtAgentSignature")
                        .WithPositionExtracted()
                        .Build();

            Signature sig2 = SignatureBuilder.SignatureFor("second.signer")
                        .WithName("IIIA_txtAgentSignature")
                        .WithPositionExtracted()
                        .Build();

            Signature sig3 = SignatureBuilder.SignatureFor("third.signer")
                        .WithName("IIIA_txtAgentSignature")
                        .WithPositionExtracted()
                        .Build();

            //add signatures depending if condition statements are met
            if(true) {
                doc.WithSignature(sig1);
            }

            if (true)
            {
                doc.WithSignature(sig2);
            }

            if (true)
            {
                doc.WithSignature(sig3);
            }

            //add your document
            packBuilder.WithDocument(doc);

            //finally build your DocumentPackage object
            DocumentPackage pack = packBuilder.Build();
            PackageId packageId = eslClient.CreatePackage(pack);

rtbike | Posts: 38

Reply to: Building Package with Multiple Signers Dynamically

0 votes
Thanks for reply I was on the correct track how ever I was having a hard time figuring out what the name of the Document Object was. Intellisense gave me Document but I missed "DocumentBuilder" Is there and object model diagram or doc someplace I can look at? Thanks, Todd

harishaidary | Posts: 1812

Reply to: Building Package with Multiple Signers Dynamically

0 votes
There is one available for the Java SDK but not for the .NET SDK. However, they are every similar, if not exactly the same. http://docs.e-signlive.com/10.0/javadoc/ Let me know if you have anymore questions =]

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