[GH-ISSUE #1716] Cannot get template fields to pre-fill when generating a document #489

Open
opened 2026-02-26 18:47:15 +03:00 by kerem · 7 comments
Owner

Originally created by @AtumG on GitHub (Mar 18, 2025).
Original GitHub issue: https://github.com/documenso/documenso/issues/1716

Issue Description

I'm trying to pass some values to fields I've defined in a template. I'm using the /api/v1/documents/{id}/generate-document endpoint and sending a post request. The document will generate and load in my Vue embed with the signer token. But non of the pre-filled fields are populated in the document and my signer is forced to fill them out.

What am I doing wrong?

Steps to Reproduce

  1. Generate a template, define text fields on that template
  2. Send a POST request to generate a document from that template

// $this->api() uses guzzle and is setting content-type, accepts, and the auth token

// To look at the field Ids
$template = $this->api()->get('/templates/'.$templateId)->json();


$this->api()->post('/templates/'.$template['id'].'/generate-document', [
            "title" => 'Listing Agreement',
            "recipients" => [
               [
                "id" => 126
                "email" => "my@email.com"
                "name" => "Name"
                "signingOrder" => 1
                "authOptions" => [
                  "accessAuth" => null
                  "actionAuth" => null
                ]
                "role" => "SIGNER"
              ]
            ],
            "prefillFields" => [
                [
                    "id" => 409, // I got this by retrieving the template and looking under the `Field` array key
                    "value" => "my prefill value"

                ],
            ]
        ])->json();
  1. Load the document in the Vue embed using the direct sign token
  2. 🛑 None of the pre-defined fields have any values.

Expected Behavior

The fields that are defined on the template should be pre-filled during document creation and visible to the end user viewing the document in the Vue embed

Current Behavior

The fields are blank

Screenshots (optional)

No response

Operating System [e.g., Windows 10]

MacOS 15.3.1

Browser [e.g., Chrome, Firefox]

Chrome

Version [e.g., 2.0.1]

134.0.6998.89

Please check the boxes that apply to this issue report.

  • I have searched the existing issues to make sure this is not a duplicate.
  • I have provided steps to reproduce the issue.
  • I have included relevant environment information.
  • I have included any relevant screenshots.
  • I understand that this is a voluntary contribution and that there is no guarantee of resolution.
  • I want to work on creating a PR for this issue if approved
Originally created by @AtumG on GitHub (Mar 18, 2025). Original GitHub issue: https://github.com/documenso/documenso/issues/1716 ### Issue Description I'm trying to pass some values to fields I've defined in a template. I'm using the `/api/v1/documents/{id}/generate-document` endpoint and sending a post request. The document will generate and load in my Vue embed with the signer token. But non of the pre-filled fields are populated in the document and my signer is forced to fill them out. What am I doing wrong? ### Steps to Reproduce 1. Generate a template, define text fields on that template 2. Send a POST request to generate a document from that template ```php // $this->api() uses guzzle and is setting content-type, accepts, and the auth token // To look at the field Ids $template = $this->api()->get('/templates/'.$templateId)->json(); $this->api()->post('/templates/'.$template['id'].'/generate-document', [ "title" => 'Listing Agreement', "recipients" => [ [ "id" => 126 "email" => "my@email.com" "name" => "Name" "signingOrder" => 1 "authOptions" => [ "accessAuth" => null "actionAuth" => null ] "role" => "SIGNER" ] ], "prefillFields" => [ [ "id" => 409, // I got this by retrieving the template and looking under the `Field` array key "value" => "my prefill value" ], ] ])->json(); ``` 3. Load the document in the Vue embed using the direct sign token 4. 🛑 None of the pre-defined fields have any values. ### Expected Behavior The fields that are defined on the template should be pre-filled during document creation and visible to the end user viewing the document in the Vue embed ### Current Behavior The fields are blank ### Screenshots (optional) _No response_ ### Operating System [e.g., Windows 10] MacOS 15.3.1 ### Browser [e.g., Chrome, Firefox] Chrome ### Version [e.g., 2.0.1] 134.0.6998.89 ### Please check the boxes that apply to this issue report. - [x] I have searched the existing issues to make sure this is not a duplicate. - [x] I have provided steps to reproduce the issue. - [x] I have included relevant environment information. - [ ] I have included any relevant screenshots. - [x] I understand that this is a voluntary contribution and that there is no guarantee of resolution. - [ ] I want to work on creating a PR for this issue if approved
Author
Owner

@github-actions[bot] commented on GitHub (Mar 18, 2025):

Thank you for opening your first issue and for being a part of the open signing revolution!

One of our team members will review it and get back to you as soon as it possible 💚

Meanwhile, please feel free to hop into our community in Discord

<!-- gh-comment-id:2734935547 --> @github-actions[bot] commented on GitHub (Mar 18, 2025): Thank you for opening your first issue and for being a part of the open signing revolution! <br /> One of our team members will review it and get back to you as soon as it possible 💚 <br /> Meanwhile, please feel free to hop into our community in [Discord](https://documen.so/discord)
Author
Owner

@AtumG commented on GitHub (Mar 18, 2025):

I've also tried to add fields to the document after creation. I'm sending a POST request to /documents/{id}/fields and this is the result:

{
  "fields": [
    {
      "id": 607,
      "documentId": 137,
      "recipientId": 256,
      "type": "TEXT",
      "pageNumber": 1,
      "pageX": 20,
      "pageY": 50,
      "pageWidth": 30,
      "pageHeight": 7.5,
      "customText": "",
      "fieldMeta": {
        "label": "Seller Name",
        "placeholder": "",
        "required": true,
        "readOnly": true,
        "type": "text",
        "text": "example value",
        "characterLimit": 40
      },
      "inserted": false
    }
  ],
  "documentId": 137
}

inserted is returning false and I don't see the field on the document. What are the reasons that inserted would return false? I assume this indicates the field wasn't actually added.

<!-- gh-comment-id:2734973919 --> @AtumG commented on GitHub (Mar 18, 2025): I've also tried to add fields to the document after creation. I'm sending a POST request to /documents/{id}/fields and this is the result: ```json { "fields": [ { "id": 607, "documentId": 137, "recipientId": 256, "type": "TEXT", "pageNumber": 1, "pageX": 20, "pageY": 50, "pageWidth": 30, "pageHeight": 7.5, "customText": "", "fieldMeta": { "label": "Seller Name", "placeholder": "", "required": true, "readOnly": true, "type": "text", "text": "example value", "characterLimit": 40 }, "inserted": false } ], "documentId": 137 } ``` `inserted` is returning false and I don't see the field on the document. What are the reasons that inserted would return false? I assume this indicates the field wasn't actually added.
Author
Owner

@zachlatta commented on GitHub (Apr 2, 2025):

Did you ever figure this out? I'm running into this same issue.

<!-- gh-comment-id:2771010834 --> @zachlatta commented on GitHub (Apr 2, 2025): Did you ever figure this out? I'm running into this same issue.
Author
Owner

@AtumG commented on GitHub (Apr 2, 2025):

I have not been able to get the prefillFields to work. I'm currently using a bit of a hacky workaroudn that is accomplishing the goal but not flawlessly.

Instead of prefilling the fields, I'm setting the text to 1 blank space in all of the fields in my template, no placeholder and leave required and readonly off. Then when I generate my document, I'm grabbing the X,Y,width,height for each field by querying the api for the template. I'm generating the document, then adding fields to that document with the add document field api. This is where I'm setting the value that I want to "merge" into that field. Since I have the coordinates of the field from the template, I'm able to add new fields directly on top of the fields in the document rather than filling them. I'm using the recipient ID from the document generation request in my add field post request.

There are some quirks to doing it this way, occasionally a field will be missing a value and when that happens it can be very unpleasant to continue through the document. I'm not exactly sure what causes it to work sometimes and others not but I assume it's related to having two fields stacked on top of each other. In my use case, I want read-only fields; this helps with the quirky loading but it also is not perfect.

When I have some more time I'm going to try a few more things to get prefilling to work correctly. I will certainly circle back to update on my findings. If this feature is actually supported, some better documentation would be really nice!

<!-- gh-comment-id:2771556386 --> @AtumG commented on GitHub (Apr 2, 2025): I have not been able to get the prefillFields to work. I'm currently using a bit of a hacky workaroudn that is accomplishing the goal but not flawlessly. Instead of prefilling the fields, I'm setting the text to 1 blank space in all of the fields in my template, no placeholder and leave required and readonly off. Then when I generate my document, I'm grabbing the X,Y,width,height for each field by querying the api for the template. I'm generating the document, then adding fields to that document with the add document field api. This is where I'm setting the value that I want to "merge" into that field. Since I have the coordinates of the field from the template, I'm able to add new fields directly on top of the fields in the document rather than filling them. I'm using the recipient ID from the document generation request in my add field post request. There are some quirks to doing it this way, occasionally a field will be missing a value and when that happens it can be very unpleasant to continue through the document. I'm not exactly sure what causes it to work sometimes and others not but I assume it's related to having two fields stacked on top of each other. In my use case, I want read-only fields; this helps with the quirky loading but it also is not perfect. When I have some more time I'm going to try a few more things to get prefilling to work correctly. I will certainly circle back to update on my findings. If this feature is actually supported, some better documentation would be really nice!
Author
Owner

@mageshmagi44 commented on GitHub (Jul 10, 2025):

running into the same issue did you find any way ?

<!-- gh-comment-id:3057616438 --> @mageshmagi44 commented on GitHub (Jul 10, 2025): running into the same issue did you find any way ?
Author
Owner

@ruohki commented on GitHub (Aug 12, 2025):

Is there a way to make the ids persist. Event he slightest template change scrambles all the ids

<!-- gh-comment-id:3180749464 --> @ruohki commented on GitHub (Aug 12, 2025): Is there a way to make the ids persist. Event he slightest template change scrambles all the ids
Author
Owner

@xenothanhojem commented on GitHub (Oct 2, 2025):

@mageshmagi44 @AtumG @ruohki @zachlatta

I applied the code level changes from this PR to my local source: https://github.com/documenso/documenso/pull/1615/commits/d25d67f7cea5a9d811b179fa65835b96fce77f26

then rebuilt. And it works when passing the requirement as per the video demos here: https://github.com/documenso/documenso/pull/1615

<!-- gh-comment-id:3360314452 --> @xenothanhojem commented on GitHub (Oct 2, 2025): @mageshmagi44 @AtumG @ruohki @zachlatta I applied the code level changes from this PR to my local source: https://github.com/documenso/documenso/pull/1615/commits/d25d67f7cea5a9d811b179fa65835b96fce77f26 then rebuilt. And it works when passing the requirement as per the video demos here: https://github.com/documenso/documenso/pull/1615
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#489
No description provided.