Use variable data as part of a report description for a summary table

  • 0
  • 1
  • Question
  • Updated 8 months ago
  • In Progress
There was a question asked a year ago (https://community.quickbase.com/quickbase/topics/adding-a-report-legend-using-report-description) regarding creating legends using html for a table report. Dan Diebolt was able to use IOL to get the legend presented. 

So heres the ask:

I have a rolling 90 day report and Im being asked to have a time line published as part of the report description. Any ways, I wanted to use 2 variables (1 which would generate todays date and another to generate [Today()-Days(90)] date) which could be pushed into the report description of a summary table.
Photo of G.Macri

G.Macri

  • 738 Points 500 badge 2x thumb

Posted 8 months ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,044 Points 20k badge 2x thumb
Use this code:
require(['moment'], function(moment) {
  var fromDate = moment().subtract(3, 'months').format('MM/DD/YYYY');
  var toDate = moment().format('MM/DD/YYYY');
  $("#introText td").html(`From ${fromDate} to ${toDate}`);
});

You can test this code from the console. Here is a screenshot with some dummy text set as the description and before the code is executed.



Here is a screenshot after the code is executed:



Notes:

1) This code uses QuickBase's chosen loader library requirejs to load the moment library which is already configured (because QuickBase uses itself uses it on various pages).

2) If you have any need to manipulate dates within your script solutions you should use the moment library as it support every conceivable date manipulation under the sun

MomentJS Library
https://momentjs.com/

If you need further assistance feel free to contact me off-world using the information in my profile:

https://getsatisfaction.com/people/dandiebolt


Photo of G.Macri

G.Macri

  • 738 Points 500 badge 2x thumb
So, I tried copying that script into Chrome Console with the report open and it didnt work. How do you get the code to initiate?
(Edited)
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,044 Points 20k badge 2x thumb
>How do you get the code to initiate?

I pasted it into the console while displaying a summary report. You may have to have some dummy text in the report description in order for QuickBase to render the description in the first place. My code merely changed the description.