Conditional reporting
Show a block only when its data matches
Select a merge block, define its condition with a form, and merge the document to see the reporting engine include or omit the block.
-
1
Configure the selected merge block
Click inside a merge block in the document. The available parent fields are loaded automatically.
Selected merge block
No merge block selected
-
2
Merge the document
Generate the result with the condition stored in the selected merge block.
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Conditional Merge Blocks
Conditional merge blocks keep business rules in the template metadata. A single template can therefore render different sections for different records without duplicating the document.
Key members
Read the selected block
TXTextControl.subTextParts.getItem
Store the condition
SubTextPart.setData
Evaluate during merge
MailMerge.MergeJsonData
How it works
The browser locates the merge-block SubTextPart containing the current input position and reads the parent record from the JSON schema. The form then writes a complete DataShapingInfo object back to the block with SubTextPart.setData.
The controller loads the modified template and merges blockdata.json. For example, the nested details block can be rendered only when its parent price field equals 200. The same pattern can be used for approval states, optional line items, and audience-specific content.
const data = {
DataShapingInfo: {
BlockMergingCondition: [condition]
}
};
selectedBlock.setData(JSON.stringify(data), callback, showError);
NuGet packages
TXTextControl.TextControl.Core.SDK
34.0.4
Provides the core document model and server-side document processing APIs.
dotnet add package TXTextControl.TextControl.Core.SDK --version 34.0.4
Provides the browser-based TX Text Control document editor and JavaScript API.
dotnet add package TXTextControl.Web --version 34.4.0
TXTextControl.Web.DocumentEditor.Backend
34.4.0
Hosts the WebSocket-based backend used by the browser document editor.
dotnet add package TXTextControl.Web.DocumentEditor.Backend --version 34.4.0