General Discussion

 View Only

Tech Talk: Implementation - Handlebars Document

  • 1.  Tech Talk: Implementation - Handlebars Document

    Posted 03-21-2024 10:01
    Edited by Ian Chamberlain 03-26-2024 10:12

    A hot topic in recent days is how we can take all this data that is being captured within TrueContext, format it in a way that your backend systems understand and send all the data once a submission has taken place on the form. One of the more universal formats that most systems will be able to understand is JSON so that is where the focus is going to be today. 

    One of the document types available in TrueContext is a Handlebars document. Handlebars (often mistaken for the handlebars on your bicycle) is a Templating Language that is used to create portable document templates. 

    When you are looking at the template below, each time you see a {{ }} that would indicate that this is either a reference to an answer or one of the helpers as listed above. Anything that is outside of the double curly brackets will be treated as plain text.  

    The easiest way to find the overall data structure that you will need to use when referencing an answer is to first build a Custom HTML or PDF document as shown in this documentation as it will show you the full structure of a form submission. You can then use the template built there and copy it into a Handlebars Template with whatever file extension you need.

    {
        "fields": {
            "Customer Name": "{{answers.CustomerName.[0]}}",
            "Inspection Date": "{{answers.Date.[0]}}",
            "Task": "{{pages.Tasks.sections.Tasks1.answers.TaskText.values.[0]}}"
        }
    }
    It can take some figuring out to understand the structure that you need to use when referencing question answers but reading through all of TrueContext's documentation and comparing it to this example should get you most of the way there. Now that you have the JSON document formatted properly, you can include this document as an attachment and will be treated as the Request Payload to a HTTP POST Destination.

    Are you using a Handlebars template in your current workflows? If so, we would love to hear about what you are doing! If not, hopefully this was some inspiration to investigate what it is all about. 

    Here is the example output of what that template produces:
    {
        "fields": {
            "Customer Name": "Home Housing Corp",
            "Inspection Date": "2024-02-22",
            "Task": "Jump Around"
        }
    }

    #TechTalkImplementation

    ------------------------------
    Ian Chamberlain
    Solutions Architect
    TrueContext
    ------------------------------



Reminder: Content posted to our Community is public content.  Please be careful not to post Intellectual Property that you do not have permission to share.  For more information please refer to our Terms Of Use