Document Generation Scripting


I could really use some help with a script. I’ve just begun to fiddle with sending data to Documint to generate different PDF documents with styling.

Maybe this isn’t possible, but here is the scenario.

We have donor, donations and funds tables.
Donors (contacts) have many donations (transactions)
Donations have one fund (category)

I would like a button on the Donor page to generate a “statement” of donation activity and summarized totals for any date range the user picks.

Here is what I have so far:
Field called “Report Dates” that the button will prompt them to complete in Step 2 for use in the script.
Total fields in Donor database that calculate different totals based on “Report Dates” selected. (Would prefer to do this on the fly somehow but that seems to add even more complexity to my ask)
Generic script for a POST to Documint (Tested and working on simpler template)

Donor and filtered donations:
If possible, how do I take the start and end dates they picked, grab only IDs of donations related to the selected contact that also fall within the selected date range, and then put that inside the POST body?

This is a very specific case but could be really helpful going forward with other reports that need to look at multiple databases and do some sort of filtering/aggregating.

Thank you!

Hi there!

I think this is possible. You will have to query your donations DB in the script. The query should look somewhat like this:

    "command": "fibery.entity/query",
    "args": {
      "query": {
        "q/from": "YOUR_SPACE/Donation",
        "q/select": ["YOUR_SPACE/name", "YOUR_SPACE/amount"],
        "q/where": [
            [">=", ["q/start", ["YOUR_SPACE/Date Range"]], "$startDate"],
            ["<=", ["q/end", ["YOUR_SPACE/Date Range"]], "$endDate"],
            ["=", ["YOUR_SPACE/Donor"], "$id"]
        "q/limit": 2
      "params": {
        "$startDate": "2023-01-01",
        "$endDate": "2023-01-20",
        "$id": "DONOR_ID"

Note that this is pseudocode and will not work :upside_down_face:

Hope this helps. If not, please share some Screenshots of your DBs and relevant fields. Then we can create the script together.


1 Like

It will take me a hot minute to digest and apply this. I appreciate the quick response and I’ll update once I’ve had time to work with it.