Products Technologies Demo Docs Blog Support Company

New ReportingCloud Endpoint: Retrieving Template Information Including Contained MergeFields and the MergeBlock Structure

The ReportingCloud /v1/templates/info endpoint returns JSON with merge field names and the nested merge block hierarchy of a stored template. The .NET wrapper exposes a TemplateInfo object, enabling dynamic scenarios like generating HTML forms from template fields before merging.

New ReportingCloud Endpoint: Retrieving Template Information Including Contained MergeFields and the MergeBlock Structure

We just released a new endpoint to the ReportingCloud Web API:

http://api.reporting.cloud/v1/templates/info

This endpoint returns information about a template located in the template storage. It returns a JSON structure with the template name, the contained merge fields, the nested merge block structure and included merge fields of the merge blocks.

The following sample CURL shows the usage and the return value:

curl -u username:password \
  -X GET "https://api.reporting.cloud/v1/templates/info?templateName=sample_invoice.tx
{
        "templateName": "sample_invoice.tx",
        "mergeBlocks": [
                {
                        "name": "item",
                        "mergeFields": [
                                {
                                        "dateTimeFormat": "",
                                        "name": "qty",
                                        "numericFormat": "",
                                        "preserveFormatting": false,
                                        "text": "«qty»",
                                        "textAfter": "",
                                        "textBefore": ""
                                }
                        ],
                        "mergeBlocks": []
                }
        ],
        "mergeFields": [
                {
                        "dateTimeFormat": "",
                        "name": "yourcompany_companyname",
                        "numericFormat": "",
                        "preserveFormatting": false,
                        "text": "«YOURCOMPANY_COMPANYNAME»",
                        "textAfter": "",
                        "textBefore": ""
                },
                {
                        "dateTimeFormat": "",
                        "name": "invoice_no",
                        "numericFormat": "",
                        "preserveFormatting": false,
                        "text": "«invoice_no»",
                        "textAfter": "",
                        "textBefore": "#"
                }
        ]
}

The wrappers implement a new TemplateInfo object that returns the merge block and merge field structure like in this sample:

using System;
using System.Collections.Generic;
using System.Drawing;
using TXTextControl.ReportingCloud;

class RCSamples
{
    public static void GetTemplateThumbnails(string templateName)
    {
        ReportingCloud rc = new ReportingCloud(
            "username",
            "password",
            new Uri("https://api.reporting.cloud"));

        try
        {
            TemplateInfo templateInfo = rc.GetTemplateInfo(sTempFilename);
            Console.WriteLine(templateInfo.TemplateName);
        }
        catch (Exception e)
        {
            Console.WriteLine("An error occurred: " + e.Message);
        }
    }
}
sample_invoice.tx

This new method allows you to retrieve the contained merge fields of a template. Consider the following scenario: You would like to create an HTML form with input elements based on merge fields of a template. Using the templates/info endpoint, you can loop through all fields in order to create input form elements for user input. After the users completed this HTML form, you can merge back the data into the template in order to create a resulting document.

Start today with ReportingCloud and sign up for a free trial account.

Happy coding!

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Cloud

Are we moving to the cloud? This question is changing from "if" to "when" and "how". Text Control ReportingCloud brings complete reporting functionality to the cloud so all developers can use it, irrespective of the platform or language they're using. Its highly RESTful API can be used to merge Microsoft Word compatible templates with JSON data from all clients including .NET, Javascript, PHP, Node.JS, jQuery, Ruby, Python, Android, Java and iOS.

See Cloud products

Related Posts

CloudReportingRelease

ReportingCloud Monthly Payment Available

ReportingCloud now supports monthly subscription plans that auto-renew each billing cycle until cancelled. Subscribers manage active plans and view payment invoices through the online store…


CloudReleaseReportingCloud

ReportingCloud: Setting the Culture for Date and Currency Fields

ReportingCloud adds a culture property to the MergeSettings object in the document/merge endpoint. Passing a Language Culture Name such as de-DE or en-US controls how currency symbols, decimal…


ASP.NETCloudConference

Visit Text Control at BASTA! 2017

Text Control exhibits at BASTA! 2017 in Mainz, showcasing the TX Text Control X15 beta with thesaurus, mini toolbar, chart ribbon tab, and background image features. The booth also demonstrates…


CloudConferenceMail Merge

More Impressions from DWX Developer Week 2017

Text Control concluded its exhibition at DWX Developer Week 2017 by holding an Xbox One raffle on the final day. The team continued demonstrating reporting products at their Nuremberg booth,…


CloudConferenceMail Merge

DWX Developer Week 2017: First Impressions

Text Control exhibited at DWX Developer Week 2017 in Nuremberg, one of Germany's largest developer conferences. The team showcased .NET reporting libraries at their booth, previewed the TX Text…

Share on this blog post on: