HTML Template Start Expression - Google Chart

@Phil I know this is kinda your babyโ€ฆ
Having issues getting a start expression to runโ€ฆ (Or maybe itโ€™s something elseโ€ฆ) Iโ€™m trying to webhook this google gantt chart html to a service that converts HTML to imagesโ€ฆ It works great with static HTML, and I was able to get it dynamic with the default date, but I canโ€™t get the recordsโ€ฆ

<html>
<head>
  <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  <script type="text/javascript">
    google.charts.load('current', {'packages':['gantt']});
    google.charts.setOnLoadCallback(drawChart);

    function drawChart() {

      var otherData = new google.visualization.DataTable();
      otherData.addColumn('string', 'Task ID');
      otherData.addColumn('string', 'Task Name');
      otherData.addColumn('string', 'Resource');
      otherData.addColumn('date', 'Start');
      otherData.addColumn('date', 'End');
      otherData.addColumn('number', 'Duration');
      otherData.addColumn('number', 'Percent Complete');
      otherData.addColumn('string', 'Dependencies');

      otherData.addRows([
        &lt;&lt;START: [VC_Task_Children]&gt;&gt;['&lt;&lt;[task_key]&gt;&gt;', '&lt;&lt;[task_key]&gt;&gt;', null, null, null, &lt;&lt;[VC_ms]&gt;&gt;, 50, null],&lt;&lt;End&gt;&gt;

      ]);

      var options = {
        height: 300,
        gantt: {
          defaultStartDateMillis: new Date(&lt;&lt;YEAR([task_mandatory_start])&gt;&gt;, &lt;&lt;MONTH([task_mandatory_start])&gt;&gt;, &lt;&lt;DAY([task_mandatory_start])&gt;&gt;)
        }
      };

      var chart = new google.visualization.Gantt(document.getElementById('chart_div'));

      chart.draw(otherData, options);
    }
  </script>
</head>
<body>
  <div id="chart_div"></div>
</body>
</html>
2 9 680
9 REPLIES 9

This here worked dynamically prior to attempting the <><>

<html>
<head>
  <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  <script type="text/javascript">
    google.charts.load('current', {'packages':['gantt']});
    google.charts.setOnLoadCallback(drawChart);

    function toMilliseconds(minutes) {
      return minutes * 60 * 1000;
    }

    function drawChart() {

      var otherData = new google.visualization.DataTable();
      otherData.addColumn('string', 'Task ID');
      otherData.addColumn('string', 'Task Name');
      otherData.addColumn('string', 'Resource');
      otherData.addColumn('date', 'Start');
      otherData.addColumn('date', 'End');
      otherData.addColumn('number', 'Duration');
      otherData.addColumn('number', 'Percent Complete');
      otherData.addColumn('string', 'Dependencies');

      otherData.addRows([
        ['toTrain', 'Walk to train stop', 'walk', null, null, toMilliseconds(5), 100, null],
		['music', 'Listen to music', 'music', null, null, toMilliseconds(70), 100, null],
        ['wait', 'Wait for train', 'wait', null, null, toMilliseconds(10), 100, 'toTrain'],
        ['train', 'Train ride', 'train', null, null, toMilliseconds(45), 75, 'wait'],
        ['toWork', 'Walk to work', 'walk', null, null, toMilliseconds(10), 0, 'train'],
        ['work', 'Sit down at desk', null, null, null, toMilliseconds(2), 0, 'toWork'],

      ]);

      var options = {
        height: 300,
        gantt: {
          defaultStartDateMillis: new Date(&lt;&lt;YEAR([task_mandatory_start])&gt;&gt;, &lt;&lt;MONTH([task_mandatory_start])&gt;&gt;, &lt;&lt;DAY([task_mandatory_start])&gt;&gt;)
        }
      };

      var chart = new google.visualization.Gantt(document.getElementById('chart_div'));

      chart.draw(otherData, options);
    }
  </script>
</head>
<body>
  <div id="chart_div"></div>
</body>
</html>

Have you tried saving the actual resulting HTML to a file and validating it and/or passing it to your conversion service?

Maybe Iโ€™ll have some time to double check itโ€ฆ I ran into some walls, and did some searching here and found some other people hitting the same issue.

@Bellave_Jayaram and @Phil Hereโ€™s what iโ€™m seeingโ€ฆ

When I build my template without paragraph marks around my START statement I get the following errorโ€ฆ When I include paragraph marks, Appsheet will run it, but the HTML is uselessโ€ฆ I am getting the vibe that the start expressions NEED something to indicate to start a new lineโ€ฆ

Failed: Action not performed because 3 errors are present. Error: Workflow rule โ€˜TestStartExpressionโ€™ action โ€˜startexpressionhtmlโ€™ Body template. Expression โ€˜START: [VC_Task_Children]โ€™ is invalid due to: Unable to find table โ€˜START:โ€™, did you mean โ€˜TASKโ€™?. Error: Workflow rule โ€˜TestStartExpressionโ€™ action โ€˜startexpressionhtmlโ€™ Body template. Expression โ€˜Endโ€™ is invalid due to: Expression refers to undefined field. Error: The document body is empty.

Template with paragraph marks, even though I canโ€™t use them:
<p>&lt;&lt;START: [VC_Task_Children]&gt;&gt;['&lt;&lt;[task_key]&gt;&gt;', '&lt;&lt;[task_key]&gt;&gt;', null, null, null, &lt;&lt;[VC_ms]&gt;&gt;, 50, null],&lt;&lt;End&gt;&gt;</p>

Result:
<p><span>['R1_L1_C1', 'R1_L1_C1', null, null, null, 86,400,000, 50, null],</span><span>['R1_L1_C2', 'R1_L1_C2', null, null, null, 158,400,000, 50, null],</span><span>['R1_L1_C3', 'R1_L1_C3', null, null, null, 3,600,000, 50, null],</span></p>

When I parse the HTML template, I look for Start, End, StartIf, and EndIf expressions inside HTML <P> and <H1> through <H6> elements. (When you use a Google Doc template it is downloaded as HTML.) A single <P> or <H> element may contain the matching Start/End or StartIf/EndIf.

The template replacement strategy relies on parsing and replacing HTML elements in the HTML DOM.

I have never considered looking for Start, End, StartIf, and EndIf expressions inside <Script> tags.
I am not sure if my existing parsing and replacement logic would handle that correctly.

If you send me a simple app that reproduces the problem I can try it.
One word of caution, Doing that may take me a while.
I am buried in other support issues at the moment.

I found a workaround, itโ€™s not pretty, but it gets me down the roadโ€ฆ More than anything just trying to understand it better.

I was looking for this information for an eternity, until finally here it was. Thank you @Phil for this answer and @Grant_Stead for starting this topic. It solves all my problems with Select: expression in HTML templates. God bless you ๐Ÿ™๐Ÿผ

Hi Grant,

Glad you found a workaround. I am still happy to try adding <Script> to the list of HTML elements I check when looking for Start/End if you like.

That would be coolโ€ฆ
Itโ€™ll make it a little more resilient for this google charts HTMLโ€ฆ

Top Labels in this Space