Question
Document Generation: Dynamic columns discard-if + context $ Title: discard-if: multiple conditions + , $ root context not working
I am using the Document Generation API with a Word template (dynamic table with table markers) and want to conditionally discard a column based on values coming from different levels of the input JSON.
I want to remove a column when either of the following conditions is true:
- The current row’s product
nameequals a specific value (row-level context), OR - A root-level boolean flag
show_pricingisfalse
{
"data": {
"approved_quote": true,
"bypass_approval": false,
"group_family": {
"products": [
{
"name": "Product A",
"items": [
{
"end_date": "31 Dec 2025",
"prices": [{ "net_price": "$100" }]
}
]
},
{
"name": "Some Other Product",
"items": [
{
"end_date": "15 Jan 2026",
"prices": [{ "net_price": "$200" }]
}
]
}
]
}
},
"show_pricing": false
}Template fragments I tried:
- {{items.end_date:discard-if(expr(name = "Product A" or $.show_pricing = false))}}
- {{items.end_date:discard-if(expr(show_pricing = false), $)}}
Tried 2nd one to test context tag is really working but, It didn’t work in my case
