Discussions

Expand all | Collapse all

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

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

    Posted 08-15-2018 18:07
    There was a question asked a year ago (https://community.quickbase.com/quickbase/topics/adding-a-report-legend-using-report-description">https://community.quickbase.com/quickbase/topics/adding-a-report-legend-using-report-description">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.


  • 2.  RE: Use variable data as part of a report description for a summary table

    Top
    Contributor
    Posted 08-19-2018 18:02
    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




  • 3.  RE: Use variable data as part of a report description for a summary table

    Posted 08-23-2018 18:08
    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?


  • 4.  RE: Use variable data as part of a report description for a summary table

    Top
    Contributor
    Posted 08-24-2018 12:47
    >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.