• Welcome to the new forum! We upgraded our forum software with a host of new boards, capabilities and features. It is also more secure.
    Jump in and join the conversation! You can learn more about the upgrade and new features here.

User-defined fields to include in custom reports

GigaFemto

Grandmaster Brewer
Joined
Oct 5, 2016
Messages
409
Reaction score
38
Location
Bay Area, California
There are some values that BeerSmith does not calculate that users would like to see in reports. There are also some people who would like to see the availability of simple math on tagged fields in custom report (e.g. estimated cooled post-boil volume = $DISPLAY_BATCH_SIZE+$TRUB_LOSS). It may be too much of a technical challenge to permit this, but I propose a workaround that might be good enough for most purposes. If BeerSmith had a set of user-defined fields that could be printed in custom reports with tags like $USER_DEFINED_1, then  users could fill those boxes with the desired numbers and have them print in the reports. Any math would still have to be done by hand, but it would make the reports cleaner. Right now I leave blank spots in my custom reports and fill them in by hand, which is a bit of a pain and seems rather retro for 2019.

--GF
 
I would love VERY much to have this... also, more access to variables.  Even if it's just $VAR_XXX and a table that we can use to look them up.  Such things like total points (cooled preboil volume x preboil SG), or displaying post-boil volume as well as "cooled" post boil volume. 

These are things items i'm scribbling down by hand on my custom brewsheets that are very helpful during brew day when trying to calculate if i need to liquor up or if something is not on par with my usual recipe.
 
Cross-posting this reply... i have found a way to get access to some variables for math functions.  I can't get any info that isn't passed, but we can use javascript to strip formatting off variables and use them with math functions to make our own variables:

I found a way around this for now... the Beersmith custom report generate uses a webkit which allows javascript to run.  That allow us to do some string manipulation and math to get things.

Here's a custom report example I have where I can get some items I wanted:
1) total points = show total gravity points at mash step in case my volumes are off, i can do quick math to figure out top up water or more aggresive boil off rates.
2) Removing " SG" from the gravity readings so they fit better on the sheet... i like to say "Est OG" which is implied SG... this allows fitting more items in a row
3) converting SG to Plato
4) shrinking the water volumes for better cals.  For example, endoing boil volume may be 6.5 at flame out but after chilling it should reduce by 4% shrinkage and be 6.25... i need to use 6.25 for math operations as well as confirmation to me that i'm spot on while draining to kettle
5) a function to show actual pre-boil OG.  Due to the issues above with how preboil OG is calculated i wrote another function... this one takes points based off "pre boil OG * pre boil volume" which appears correct.. then divides it by the "shrunk" pre-boil volume to get a correct room temp reading for Preboil SG

Place this in the "head" section of your custom report:
Code:
<script>
<script>
var og = '$EST_OG';
var fg = '$EST_FG ';
var pog = '$PRE_BOIL_OG';
var prevol = '$DISPLAY_BOIL_SIZE';
var postvol = '$POST_BOIL_VOLUME';

function remove_sg(item) {
  // function to remove " SG" from end of SG so math can be performed
  return item.slice(0, 5);
}

function total_points() {
  // function to calc total points for use in adhoc math dring brewday
  // Unable to use EST_OG here due to later added adjuncts and no ability
  // to seperate the PPG of Sugard, etc.
  var vol = prevol.split(" ")[0];
  var sg = pog.slice(2, 5);
  return (vol * sg).toFixed(1)
}

function sg_to_plato(gravity) {
  // convert SG to plato for display purposes
  // plato = (-1 * 616.868) + (1111.14 * sg) ? (630.272 * sg^2) + (135.997 * sg^3)
  var sg = gravity.slice(0, 5);
  var plato = (-1 * 616.868) + (1111.14 * sg) - (630.272 * Math.pow(sg, 2)) + (135.997 *  Math.pow(sg, 3));
  return plato.toFixed(1);
}

function vol_shrink(volume, shrinkage) {
  //  reduce the "volume" of liquid by the shrinkage amount...  
  var vol = volume.split(" ")[0]
  vol = vol / shrinkage; // take out the 4% that was added due to heat
  return vol.toFixed(2);
}

function actual_preog() {
  // function to back-calculate the correct preboil SG based
  // on total points and a "room temp" sample instead of "hot" sample
  var points = remove_sg(pog).slice(2, 5) * prevol.split(" ")[0];
  var actualPreOG = points / vol_shrink(prevol, 1.03);
  return (actualPreOG / 1000 + 1).toFixed(4);
}


function populate_custom_vars() {
  document.getElementById("estOG").innerHTML = remove_sg(og);
  document.getElementById("estFG").innerHTML = remove_sg(fg);

  document.getElementById("platoOG").innerHTML = sg_to_plato(og);
  document.getElementById("platoOG2").innerHTML = sg_to_plato(og);
  document.getElementById("platoFG").innerHTML = sg_to_plato(fg);
  document.getElementById("plato_preOG").innerHTML = sg_to_plato(actual_preog())

  document.getElementById("actual_preOG").innerHTML = actual_preog();
  document.getElementById("actual_preOG2").innerHTML =actual_preog();

  document.getElementById("preboil_vol_shrinked").innerHTML = vol_shrink(prevol, 1.03) + " gal";
  document.getElementById("postboil_vol_shrinked").innerHTML = vol_shrink(postvol, 1.04) + " gal";

  document.getElementById("total_points").innerHTML = total_points();
}
</script>

Then you can space the Element-id's around as such:
Code:
 <div id="wrapper">
        <div id="header">
            <div class="logo">
               <h1>$NAME</h1>
               <h2>$STYLE_NAME ($STYLE_NUMBER $STYLE_LETTER)</h2>
            </div>
        </div>
        <table>
            <tr>
                <td width="25%">
                    <div class="col4">
                        <span class="item">Batch:</span> $DISPLAY_BATCH_SIZE

                        <span class="item">SRM:</span> $EST_COLOR

                        <span class="item">IBU:</span> $IBU

                        <span class="item">Est ABV:</span>  $EST_ABV

                    </div>
                </td>

                <td width="25%">
                    <div class="col4">
                        <span class="item">Packaged Vol:</span> $BOTTLING_VOLUME

                        <span class="item">Est Mash Eff:</span> $EST_MASH_EFFICIENCY

                        <span class="item">Est BH Eff:</span> $EFFICIENCY %

                        <span class="item">Boil time:</span>  $BOIL_TIME min

                    </div>
                </td>

                <td width="25%">
                    <div class="col4">
                        <span class="item">Est OG:</span> <span id="estOG"></span> (<span id="platoOG"></span> P)

                        <span class="item">Est FG:</span> <span id="estFG"></span> (<span id="platoFG"></span> P)

                        <span class="item">Preboil Vol:</span> $DISPLAY_BOIL_SIZE

                        <span class="item">Preboil SG:</span> <span id="actual_preOG"></span> (<span id="plato_preOG"></span> P)

                    </div>
                </td>

                <td width="25%">
                    <div class="col4">
                        <span class="item">Recipe Date:</span> $DATE

                        <span class="item">Total Grain:</span> $TOTAL_GRAINS

                        <span class="item">Brewing Date: _____________</span>

                        <span class="item">Packaging Date: ___________</span>

                    </div>
                </td>
            </tr>
        </table>
...

        <ul class="checklist">
            <li>Switch power off HLT and set BK ALM</li>
            <li>$SPARGE_STEPS (Total $SPARGE_VOLUME)</li>
            <li>Measure pre-boil gravity _________   (target: $PRE_BOIL_OG, <span id="actual_preOG2"></span> SG, total points <span id="total_points"></span>)</li>
            <li>Measure pre-boil volume _________   (target: $DISPLAY_BOIL_SIZE, <span id="preboil_vol_shrinked"></span>)</li>
            <li>Sanitize bucket, airlock, o2, all remaining cold side equipment</li>
        </ul>

...

This will hold  me over for now... i have the BS estimated preboil SG, the actual expected SG, the "expanded" or "hot" volume of preboil water as well as the "cooled" volume if i need to do any quick math (SG * cooled volume = total points, divide by expected volume to get new OG... etc).

This produces outputs like this:
Code:
Batch: 6.25 gal     Packaged Vol: 5.00 gal  Est OG: 1.056 (13.8 P)          Recipe Date: 03/12/20
SRM: 7.0 SRM        Est Mash Eff: 80.0 %    Est FG: 1.015 (3.8 P)           Total Grain: 12.04 lb
IBU: 40.4 IBUs      Est BH Eff: 80.00 %     Preboil Vol: 8.01 gal           Brewing Date: _____________
Est ABV: 5.3 %      Boil time: 60 min       Preboil SG: 1.0443 (11.0 P)     Packaging Date: ___________

*** NOTE, i've chosen to include an extra decimal place in pre-boil OG because that rounding error can be important when using that for math later.
 
gizzygizmo,
  I got all excited when I saw this, but i can't get it to work for me. Something is missing and I just get no output from the <span id="actual_preOG"></span> and other references to ids. I even tried a simple var water = "$TOTAL_WATER" in the header and then later <span id="water"></span> in the body (i.e. no use of the functions at all) and it still didn't work. Can  you post your entire custom report so can I try to figure out what I am missing?

Also, what version of BeerSmith are you using?

--GF

Update - after hours of experimenting I have something working. I had to organize things very differently from you to get it to work, but just knowing that script could be used gave me enough motivation to persist.
 
I know it's an old post... curious what you had to do differently to get it working.  I've shared these javascript additions with some folks and if i need to modify them in a certain way to make it better for the internet as a whole that would be ideal.  I'd hate for someone confused about SG/preboil volumes to find this on an internet search and have no luck.
 
The variable definitions and function definitions can go in the <script>...</script> section at the beginning of the file, but I found I had to place the "document.getElementById()..." statements at the end, in another <script>...</script> section after the <span>...</span> statements in order for the values to show up properly. It doesn't make any sense to me to fill the variables with values after you have referenced and used the values, but I guess it is not something that is processed in order from top to bottom.

I have since given up on BeerSmith reports for brewsheets. I thought that this script approach would allow me to access values and do math on them, but not every value is accessible this way. My current solution is to export the recipe to an xml file which is imported into Excel. There are still some missing values (such as target pH), but you get almost everything including all the internal contents of tables. Then I can do any math I want in Excel and print out part of the worksheet as a brewsheet. I still use BeerSmith reports for printing recipes, which is much simpler then printing brewsheets.

--GF
 
I know this is an old thread, but it helped me to figure out how to use java script to calculate a custom volume from standard tags and then to use it in a custom report. Thanks gizzygizmo and GigaFemto! Thought I'd share my script in case it helps anybody else. My objective was to report the cooled, post boil volume in my kettle after removing the trub and chiller, but still accounting for kettle dead space. I am by no means a programmer, but here's the script I put in my custom report:

Code:
<script>
// This script will determine post boil volume just before transfer to fermenter, which accounts for cooling shrink,
// and losses due to trub and chiller volume, but doesn't include kettle dead space.  Example: Wort is chilled, and an
// immersion chiller and hop basket (with hop matter) are removed from the boil kettle prior to taking the final volume measurement.  
// Report usage example: Instead of using the $POST_BOIL_VOLUME tag in the custom report, use html <span id="RealPostBoilVol"></span>
// Similar methodology can be used to create other user calculations with any other tag.
 
var pbv = "$POST_BOIL_VOLUME"; //Beersmith tag for post boil volume
var pbvnum = Number(pbv.replace(" gal", "")); //strips the number out and makes it usable for math
var tl = "$EQUIPMENT.DISPLAY_TRUB_CHILLER_LOSS"; //Beersmith tag for trub and chiller losses
var tlnum = Number(tl.replace(" gal", "")); //strips the number out and makes it usable for math
var kdeadspace = 0.1 //kettle dead space, in gallons
var cp = "$EQUIPMENT.COOLING_LOSS_PCT";  //Beersmith tag for cooling loss percent
var shrink = 1 / ((cp / 100) + 1); //shrunk volume
var RealPostBoilVol = (pbvnum - tlnum) * shrink + kdeadspace; //My custom post-boil volume
var batchsize = "$DISPLAY_BATCH_SIZE"; //Beersmith tag for batch size (for OP)
var batchsizenum = Number(batchsize.replace(" gal", "")); //strips the number out and makes it usable for math
var CooledPostBoilVol = batchsizenum + tlnum; //custom post-boil volume for OP

document.getElementById("RealPostBoilVol").innerHTML = RealPostBoilVol.toFixed(2); //my post-boil volume
document.getElementById("CooledPostBoilVol").innerHTML = CooledPostBoilVol.toFixed(2); //OP's post-boil volume
</script>
 
Back
Top