Tap Forms JavaScript Scripting 102
Forms, Records, Fields, Values
by T. L. Ford

Section 6: An Automated Database Documenter

Let's apply some of what we have learned so far.

A long time ago on a webpage far, far away...

We learned that these are objects we can access, and that each of these objects has methods and properties that we can use, and that these methods and properties are documented in the Tap Forms JavaScript API.

We can use that knowledge to create a report that documents our database for us. Let's start with a simple script framework on our Reports form. We'll eventually create a Reports record and store it there, but for debugging, it's easier to send it to the console.

We'll start at the top object and work our way down through the objects.

Here's the database name and ID. We can use JavaScript's string method toUpperCase() to capitalize the database name. You can find a list of JavaScript's string methods here: https://www.w3schools.com/js/js_string_methods.asp.

I feel powerful already! Let's add a list of forms.

This works because the document object has a getForms() method that returns an array of form objects.

When we have an array, we know we can use the Basic loop snippet to go through each element, doing what we need with it.

You may notice that the title for the Forms section is outside of (above) the loop. We don't want that title repeated for each form.

This report output just looks so cool that I want to list fields too! Luckily, there's a method for that!

That returns an array of field objects.

What do we have in the Tap Forms JavaScript API documentation for fields that would be nice to include?

From that, we can build a nested for loop. Nested just means that there's a loop inside of a loop. We can't use the same variable names, but the code structure is the same.

Let's just add a few statistics, like form, field, and record counts. We know that the length property of an array tells us how many elements are in the array.

Run it again.

That is one sexy report! Time to store it in our Reports form. We can just take the code from our other script.

Now we can run the Document Database script from the pulldown and have a new report record.

Using the Tap Forms object model and the Tap Forms JavaScript API documentation, we could modify our script to also document pick lists, named searches, and scripts.

NEXT - Section 7: Sorting