mbilensky

Unable to Apply Layout with Placeholders that Specify Both ID and Description

0 votes
Hello, I am running into an issue when using a layout that was created with placeholders that specify both an ID and a description. The layout can be successfully created and viewed, but the layout cannot be applied to a package. This only seems to occur when creating placeholders with both an ID and description specified as using the same layout but only specifying IDs for placeholders will allow the layout to be applied to the package. Is this a eSignLive issue or am I doing something wrong? Here's the exception that I get when trying to apply a layout created with placeholder which specifies both an ID and Description:
Exception in thread "main" com.silanis.esl.sdk.internal.EslServerException: Could not apply layout. Exception: HTTP POST on URI https://sandbox.esignlive.com/api/packages/-wqoXrzanpHBLLqwRlIla6rZaEw=/documents/packageDocumentId/layout?layoutId=TWyrFYtJmZpcOc7IV6mEswpkwp8= resulted in response with status code: [500, Internal Server Error]. Optional details: {"messageKey":"error.internal.default","message":"Unexpected error. We apologize for any inconvenience this may have caused you, please try again. If the problem persists, please contact our support team.","code":500,"name":"Unhandled Server Error"} at com.silanis.esl.sdk.service.LayoutService.applyLayout(LayoutService.java:110) at esignature.layout.LayoutErrorExample.execute(LayoutErrorExample.java:84) at esignature.layout.LayoutErrorExample.main(LayoutErrorExample.java:26) Caused by: com.silanis.esl.sdk.internal.RequestException: HTTP POST on URI https://sandbox.esignlive.com/api/packages/-wqoXrzanpHBLLqwRlIla6rZaEw=/documents/packageDocumentId/layout?layoutId=TWyrFYtJmZpcOc7IV6mEswpkwp8= resulted in response with status code: [500, Internal Server Error]. Optional details: {"messageKey":"error.internal.default","message":"Unexpected error. We apologize for any inconvenience this may have caused you, please try again. If the problem persists, please contact our support team.","code":500,"name":"Unhandled Server Error"} at com.silanis.esl.sdk.internal.RestClient.execute(RestClient.java:192) at com.silanis.esl.sdk.internal.RestClient.post(RestClient.java:105) at com.silanis.esl.sdk.service.LayoutService.applyLayout(LayoutService.java:108) ... 2 more
Here's the sample code that I've been using to test this issue. You should be able to run this by just specifying the input streams for the document and layout as well as create the EslClient. Notice that of the three different ways that Placeholder constructor is used only the first causes the exception. I've also attempted to use both the "customId" and "replacing" on the signer when building the package that the layout is applied to, but neither is successfully working when using both ID and description is specified for the placeholder.
    // Create the placeholder with both an ID and description - Causes Exception
    Placeholder placeholder = new Placeholder("customId", "description");
    
    // Create the Placeholder by only an ID
    //Placeholder placeholder = new Placeholder("customId");
    
    // Create the Placeholder using duplicate values for ID and description
    //Placeholder placeholder = new Placeholder("customId", "customId");
    
    // Create Layout to apply to the package   
    DocumentPackage eslLayoutPackage = PackageBuilder.newPackageNamed("layoutPackage")
      .withDocument(
        DocumentBuilder.newDocumentWithName("layoutDocumentName")
          .withId("layoutDocumentId")
          .fromStream(layoutStream, DocumentType.WORD)
          .withSignature(SignatureBuilder.signatureFor(placeholder).onPage(0).atPosition(150, 150))
        .build()
      )
      .withSigner(
        SignerBuilder.newSignerPlaceholder(placeholder).build()
      )
    .build();
    
    PackageId layoutPackageId = eslClient.createPackage(eslLayoutPackage);
    eslLayoutPackage.setId(layoutPackageId);
    String eslLayoutId = eslClient.getLayoutService().createLayout(eslLayoutPackage);
    eslLayoutPackage.setId(new PackageId(eslLayoutId));    
    
    // Create Package
    DocumentPackage eslPackage = PackageBuilder.newPackageNamed("packageName")
      .withSigner( SignerBuilder.newSignerWithEmail("[email protected]")
        .withFirstName("First")
        .withLastName("Last")
        //.withCustomId(placeholder.getId())
        .replacing(placeholder)
      )
      .withDocument(DocumentBuilder.newDocumentWithName("packageDocumentName")
        .withId("packageDocumentId")
        .fromStream(documentStream, DocumentType.WORD)
      )
    .build();
    
    PackageId eslPackageId = eslClient.createPackage(eslPackage);
    eslPackage.setId(eslPackageId);

    eslClient.getLayoutService().applyLayout(eslPackage.getId(), "packageDocumentId", eslLayoutId);

Reply to: Unable to Apply Layout with Placeholders that Specify Both ID and Description

0 votes
Hi there, If you look at the Placeholder constructor on line 19 (https://github.com/eSignLive/esl.sdk.java/blob/bd58ae1ec3d117854fd58220c9ec68b3d3179957/sdk/src/main/java/com/silanis/esl/sdk/Placeholder.java), you can see that the parameters are "id" and "name". There isn't a parameter for description. Now if you're saying that Placeholder placeholder = new Placeholder("customId", "description"); is throwing an exception, I'm inclined to say that it might have something to do with the length of the String (since Placeholder placeholder = new Placeholder("customId", "customId"); isn't throwing one). Can you try reducing the description to 64 characters as that is the maximum you can go through the web UI?
Haris Haidary OneSpan Technical Consultant

Reply to: Unable to Apply Layout with Placeholders that Specify Both ID and Description

0 votes
Hi Haris, Sorry about the name/description confusion we've been using the terms interchangeably when talking about the issue. As for the length of the String, that example code is using the actual piece of text "description" and is not a placeholder for a longer piece of text, I've also just tried with a single character to be sure and the issue still occurs. For the Placeholder("customId", "customId"); example, that was just included to show that using the placeholder constructor with both parameters will only seem to work when both of the parameters are identical. Is this an eSignLive issue?

Reply to: Unable to Apply Layout with Placeholders that Specify Both ID and Description

0 votes
Hi Haris, I think if found the underlying issue, it looks like there's a bug in the LayoutService applyLayout code. It seems that when applying the layout to the document, the method looks to be trying to match the name of the placeholder specified in the layout to the ID of the placeholder specified in the SignerBuilder.replacing method of the end package. Here's some sample code showing this in action. Notice the two different placeholders, one for the layout and one for the signer of the end package, while they have different ids and names the second placeholder's id is the same as the first placeholder's name. After running the code, even though the ids and names of the placeholders are different, the signature created in the layout is successfully applied to the end package and can be signed successfully. Also notice that if you use either placeholder in both locations, the layout can no longer be applied. Please take a look at this and run the sample code provided to see if you can confirm this as a bug in eSignLive
    //ID of the package signer placeholder must match the name of layout placeholder
    Placeholder layoutPlaceholder = new Placeholder("anyId", "mustMatch"); 
    Placeholder packageSignerPlaceholder = new Placeholder("mustMatch", "anyName"); 

    // Create Layout to apply to the package   
    DocumentPackage eslLayoutPackage = PackageBuilder.newPackageNamed("layoutPackage")
      .withDocument(
        DocumentBuilder.newDocumentWithName("layoutDocumentName")
          .withId("layoutDocumentId")
          .fromStream(layoutStream, DocumentType.WORD)
          .withSignature(SignatureBuilder.signatureFor(layoutPlaceholder).onPage(0).atPosition(150, 150))
        .build()
      )
      .withSigner(
        SignerBuilder.newSignerPlaceholder(layoutPlaceholder).build()
      )
    .build();

    PackageId layoutPackageId = eslClient.createPackage(eslLayoutPackage);
    eslLayoutPackage.setId(layoutPackageId);
    String eslLayoutId = eslClient.getLayoutService().createLayout(eslLayoutPackage);
    eslLayoutPackage.setId(new PackageId(eslLayoutId));

    // Create Package
    DocumentPackage eslPackage = PackageBuilder.newPackageNamed("packageName")
      .withSigner( SignerBuilder.newSignerWithEmail("[email protected]")
        .withFirstName("First")
        .withLastName("Last")
        .replacing(packageSignerPlaceholder)
      )
      .withDocument(DocumentBuilder.newDocumentWithName("packageDocumentName")
        .withId("packageDocumentId")
        .fromStream(documentStream, DocumentType.WORD)
      )
    .build();
    
    PackageId eslPackageId = eslClient.createPackage(eslPackage);
    eslPackage.setId(eslPackageId);

    eslClient.getLayoutService().applyLayout(eslPackage.getId(), "packageDocumentId", eslLayoutId);
Thanks, Mitch

Reply to: Unable to Apply Layout with Placeholders that Specify Both ID and Description

2 votes
Hi Mitch, I think the underlying problem is that you can't have placeholders in a package, or at the very least shouldn't attempt to have one. For example, if you go to the web UI and attempt to place a placeholder in a package sitting in draft, you will get an error. Layouts should be created from an existing package or using dummy signer information. Placeholders are meant to be used in templates. I personally wouldn't recommend using layouts or templates if you're integrated, as your code serves as a layout or template. I can show the code above to our maintenance team check if this is indeed a bug. However, I don't believe this something that will be fixed in the next SDK version.
Haris Haidary OneSpan Technical Consultant

Reply to: Unable to Apply Layout with Placeholders that Specify Both ID and Description

0 votes
Hi Haris, If you are looking at the latest example code, I'm not adding any placeholders to the end package, I'm just telling the signer in the end package what placeholder it should be replacing when the layout is applied. Also, no error occurs when creating the package at all, the exception is only thrown when attempting to apply the layout.

Reply to: Unable to Apply Layout with Placeholders that Specify Both ID and Description

0 votes
Hi Mitch, Have a look at this example on our GitHub page: https://github.com/eSignLive/esl.sdk.java/blob/170d8d1de8f22760e1b23953033d13038d43f7ea/sdk/src/main/java/com/silanis/esl/sdk/examples/DocumentLayoutExample.java. It shows you how to create a layout from a package and how to apply it. Placeholders were never really meant to be used with layouts. On line 29 of your code, you're using .replacing() call to replace a placeholder, but there isn't a placeholder to be replaced (you're essentially creating a new package with a signer and a document). The .replacing() call is used when you have a template with a placeholder and you're looking to create a new package from it while replacing the placeholder with a new signer information: https://developer.esignlive.com/guides/feature-guides/create-package-from-template/
Haris Haidary OneSpan Technical Consultant

Reply to: Unable to Apply Layout with Placeholders that Specify Both ID and Description

0 votes
Hi Haris, If you run the above code and view the end package you'll notice the the signer is replacing the placeholder from the layout after calling the LayoutService.applyLayout method for that package, you can confirm that by seeing that the signature created for the layout placeholder has correctly been assigned to the signer in end package. Also note that the layout has still applied it's signatures to signers of the package even though the placeholders used in lines 15 and 29 have neither the same ID or name.

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