Skip to main content
Question

YAML Document Template - Save PDF to field in record

  • March 21, 2025
  • 0 replies
  • 86 views

Forum|alt.badge.img+6

I saw this YAML on another discussion board but it throws a jinja error in the Body of the HTTP request that says "This field contains invalid jinja references"

# Doc Gen Testing
#

# Account slugs:
#  - quickbase[CHANGE ME]: Realm Default Account <None>
#  - microsoft-outlook[CHANGE ME]:
#    <None>
---
- META:
    name: Doc Gen Testing
- ACTION quickbase[CHANGE ME] quickbase_api make -> a:
    inputs:
      method: GET
      url: https://api.quickbase.com/v1/docTemplates/1/generate?tableId=DBID_CHANGE_ME&format=pdf&pageSize=Letter&filename=Invoice&margin=1
        1 1 1&unit=in&orientation=portrait&recordId=1
    name: Generate Doc
- ACTION quickbase[CHANGE ME] quickbase_api make -> b:
    inputs:
      body: "{\n    \"to\": \"CHANGE_ME_TABLE_ID\",\n    \"data\": [\n      {\n        \"6\"\
        : {\n            \"value\": {\n                \"fileName\": \"{{a.json.fileName}}\"\
        ,\n                \"data\": \"{{a.json.data}}\"\n              }\n      \
        \  }\n      }\n    ],\n    \"fieldsToReturn\": []\n  }\n      }\n    }\n \
        \ ]\n}\n    \"fieldsToReturn\": []\n  }"
      method: POST
      url: https://api.quickbase.com/v1/records
    name: Save File to a Table
    note: 'Write the record '
- LOOKUP quickbase[CHANGE_ME] record look_up -> c:
    inputs-meta:
      table: '"Demo App: Invoice Files" <CHANGE_ME>'
      export_fields: '"File" <6>'
    inputs:
      id: '{{b.json.metadata.createdRecordIds[0]}}'
- ACTION microsoft-outlook[CHANGE_ME] email send_email_attachment -> d:
    inputs-meta:
      attachments:
        name: '{{c.file.file_name}}'
        url: '{{c.file.file_transfer_handle}}'
    inputs:
      body: Testing writing doc to QB table, looking up that record to get the file
        transfer handle, then emailing it using the outlook channel
      subject: Doc Gen Testing
      to_addresses: CHANGE_ME

Any help is appreciated.  In essence I am trying to save a document template for a record to an attachment field in that record.  Thank you!

Maria
Forum|alt.badge.img+19
  • Quickbase Alumni
  • March 21, 2025

Right. Looks like you got this from Document creation - Save PDF to field in record | Qrew Discussions 

There's more for you to update in that template. I see that you updated the table ID in your screenshot but the Jinja is also referring to Field ID #6. I suspect that field ID #6 is not named [fileName] in your app. 
~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ 
These are also relevant posts: 
Automatically save a form page as PDF and insert into attachment field? | Qrew Discussions 

PDF Document Generator, automatically attached to a record | Qrew Discussions 
~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ 
The general consensus from the power users in the comments is that it is just easier to used Juiced Tech's tool. I only point this out because if anyone could build this themselves it would be MarkShnier__You, but his recommendation is to just use the tool. I respect anyone who attempts to build a solution for themselves LijaHarris but sometimes it's also important to know when it's not worth reinventing the wheel.

We'll be here to answer your questions either way you decide to go. :)