Mileage Tracker (Tap Forms 5.3)

Tagged: 

Viewing 12 reply threads
  • Author
    Posts
  • October 11, 2018 at 10:20 AM #30998

    Brendan
    Keymaster

    I created a mileage tracker form but posted it in the regular forum. Figured I should post it here for everyone to download. It requires Tap Forms 5.3 at a minimum because it uses JavaScript to copy the previous mileage value to a new record. You need to select a record and then run the script. Tap Forms will create a new record and copy over the values from the selected record to the new record.

    Use the Import Tap Forms Archive function to import this file.

    Thanks!

    Brendan

    Attachments:
    You must be logged in to view attached files.
    November 25, 2018 at 9:48 PM #32071

    Ryan M
    Participant

    Thought I’d play around and see if I could come up with a different approach to the same mileage tracker. This would probably be closer to a fuel log rather than a simple mileage tracker.

    The inputs would be:

    – odometer value
    – Price per gallon
    – Gallons filled

    A script would calculate your mileage since last fill up as well as your miles per gallon.

    The script uses the default created date field to sort all records by their created date. This assumes that you’re entering in your mileage log around the time you filled up.

    Here’s the script for those interested

    
    var odometer_id = 'fld-9674e316bfed408ca6710ce81b72bf05';
    var vehicle_id = 'fld-64b0b17a635f49b8b40867e45f8d24db';
    var date_created_id = 'fld-2097149a2eeb4d4e892f13b62de6b5ea';
    
    // sort records in ascending order by date value
    var dateSorter = (a, b) => 
      a.getFieldValue(date_created_id) - b.getFieldValue(date_created_id)
      
    
    var run = () => {
      var vehicle = record.getFieldValue(vehicle_id);
      var odometer = record.getFieldValue(odometer_id);
    
      var records = form.getRecords()
        .filter(r =>  r.getFieldValue(vehicle_id) === vehicle)
        .sort(odometerSorter)
    
      var odometerValues = records.map(r => r.getFieldValue(odometer_id));
      var currentRecordIndex = odometerValues.indexOf(odometer);
      var previousRecordIndex = currentRecordIndex === 0 ? 0 : currentRecordIndex - 1
                     
      var mileageValue = odometerValues[currentRecordIndex] - odometerValues[previousRecordIndex]
    
      return mileageValue;
    }
    
    run();
    
    
    Attachments:
    You must be logged in to view attached files.
    November 25, 2018 at 10:42 PM #32074

    Brendan
    Keymaster

    Hi Ryan,

    For some reason Askimet flagged your response as spam. But I noticed it and marked it as not spam so it shows up now.

    Thanks for posting your alternative for the mileage tracker!

    Brendan

    November 25, 2018 at 10:43 PM #32075

    Ryan M
    Participant

    I was wondering what happened. Thanks, Brenden!

    December 5, 2018 at 11:36 AM #32411

    Chris Stovall
    Participant

    I have TapForms 5.3.4 but I can’t open the attached file. I tried in the finder and also doing a file/open. Not luck either way. What am I missing?

    December 5, 2018 at 2:08 PM #32415

    Brendan
    Keymaster

    Hi Chris,

    This is a Tap Forms Archive file. Use the Import Tap Forms Archive command in the File menu to import it.

    Thanks!

    Brendan

    April 9, 2019 at 6:04 PM #34366

    Tom Mihalic
    Participant

    I’m new here. How do i open the mileage tracker app? Tt is a .tfarc file.

    April 9, 2019 at 6:34 PM #34367

    Brendan
    Keymaster

    Hi Tom,

    Use the Import Archive command to import the mileage tracker .tfarc file. So you must first have a document opened. Then import the file.

    Thanks!

    Brendan

    November 6, 2019 at 11:36 PM #37893

    Joshua Kroll
    Participant

    Hi all!

    These are great. I’m brand new to TF and was wondering if these work on the iOS too?

    Thanks!

    November 6, 2019 at 11:52 PM #37894

    Brendan
    Keymaster

    Hi Joshua,

    Yes, this example definitely works on iOS too.

    Thanks,

    Brendan

    November 8, 2019 at 8:58 PM #37938

    Joshua Kroll
    Participant

    Thanks Brendan,

    Different question: I’m not good with scripting, but I thought maybe something may already exist that takes this a step further. Do you know if there is a script that I can put in a preset “start” address so that when I put in the destination, the milage is populated automatically?

    I do a LOT of driving and need to track the milage. Something that simple would be awesome!

    Just started with the iOS version and am very impressed so far! Thanks for a great product and great support.

    Best,
    Josh

    November 8, 2019 at 11:48 PM #37946

    Brendan
    Keymaster

    Hi Joshua,

    That would require routing information. There’s probably a Google API you can use to get the mileage given two end-points. But you’d have to do some research on that. You can use a Script to call out to a web service API and get the results which you could then store back in Tap Forms.

    The Scripts topic in the online manual has an example of calling an online UPC web service that retrieves movie details. It would give you an idea how to call out to a web service. You just have to find the right web service to give you the results you’re looking for.

    https://www.tapforms.com/help-mac/5.3/en/topic/scripts

    The script I wrote for this mileage tracker simply copies the odometer reading from the selected record to a new record, then selects the new record.

    November 9, 2019 at 1:11 AM #37950

    Sam Moffatt
    Participant

    I’d suggest looking at a tool like Automatic that will automatically record your trips for you. I bought a gen 2 model from them and it is generally gooda about recording trips and uploading them. Then you can export the CSV from the Automatic Dashboard and import that into Tap Forms as a set of records. Here’s a custom layout with a sample record from Automatic:

    I went with an approach of splitting the start and end with their fields aligned at the top and the location fields immediately below it. This two panel style also naturally helps compact some of the other details. As you can see it sometimes doesn’t get the location fully detailed but the geo point generally gets it. In theory you can hook up API access to Automatic but I find you can export the data when you care about it. The JSON format has more data in it than what they export as CSV though but you can see it likely has what you need.

    I’ve personally moved onto another OBD adapter that gives me a lot more low level detail but the Automatic adapter worked reasonably well for me for three years I was using it. They deprecated that Adapter and I chose to move on. The newer adapter gives me second level precision which is useful but creates really large log files. If you want a mostly turn key solution, Automatic is the way to go.

    I’ve also attached my refueling log entries script. When I refuel my car, I write down the details from the car’s computer (trip distance, odo, estimated range (before and after refueling), MPG/MPH and drive time. Comes with a layout I use for side by side data entry. I use VueScan to do my initial import of the receipt which creates a new Tap Forms record I can transcribe the details from later.

    Attachments:
    You must be logged in to view attached files.
    November 13, 2019 at 10:42 PM #38040

    Jack Young
    Participant

    Made some changes for a simple business mileage tracker.

    Attachments:
    You must be logged in to view attached files.
Viewing 12 reply threads

You must be logged in to reply to this topic.