Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
March 5, 2020 at 5:56 PM #39759
In reply to: Query to display selected records
Tim W
ParticipantOK I think I get it now – this database uses javascript rather than SQL to query it directly. My javascript skills are pretty rudimentary, and even with the API, I’m struggling to write working code.
The first form is just for data entry. The second form is for the ‘query’ – one field with a combo box using the values of the other form’s username field and another field set as script type.
So what I’m trying to achieve is to select an entry from the combo box and it should display a table with the matching results. I know I need to set the variables and run a loop through the index of all records in the first form. I don’t have a clue how to output that data though – something like a ‘link to form’ table would be perfect.
This isn’t correct but it’s what I have so far:
var query_user = record.getFieldValue('fld-abcd'); var sites = record.getFieldValue('fld-1234'); for (var index = 0, count = sites.length; index < count; index++) { var sitename = sites[index].getFieldValue('fld-1111'); var url = sites[index].getFieldValue('fld-2222'); var username = sites[index].getFieldValue('fld-3333'); if (username=query_user) { sitename; url; } else { } }March 5, 2020 at 3:07 PM #39754In reply to: Creating a Gym Workout Log
Sam Moffatt
ParticipantLet’s do the simple piece first: workouts and exercises. Workout is the main form and there is a Link to Form Many to Many (M:M) to Exercises (assuming that some exercises may happen in multiple workouts). That’s the easy part.
A challenge here is that you need a field to define ordering and maybe different workouts have different orders of exercise which would mean you need to have another form to track the order of the exercise in the workout. Maybe ordering of the exercises in a workout isn’t important though I suspect it might be. If that is important, you’d need a third form to store that ordering information that would be linked to workout and exercise. Alternatively you duplicate the exercises and use a One to Many and embed the ordering that way (pro: only two forms; con: duplicated data).
The next step is that you want to track, per day, each of the workouts with the sets. I’d create a form for tracking each day you work out. The basis of this form feels like it should have a field for the day you worked out and a Link to Form M:M to your workouts because your workout defines what exercises you should do. That leads to the next piece: recording the sets and the weights/reps done per set.
A way of approaching this would be to have the day form that tracks each day you work out. This is useful for creating Link to Form JOIN fields that automatically aggregate all sets on a given day for example. This may or may not be useful to you, you’d have to play with to see. The next piece would then be to have a separate form for each set. Each set you do would have a date field in it and I’d use a Link to Form field with the JOIN type on the date fields to JOIN them together. In both the days and sets forms have the date fields enabled with “Set Current Date”. This will make it easy to just create records and Tap Forms sets up the value correctly. This gives you a quick way of filtering what sets you did on a given day and the JOIN automatically links them together.
From here I’d create a new Link to Form 1:M field between exercises and sets. This assumes a workflow where you start with a workout, go into the linked exercises for it and then you create a new set for that exercise. When you create the set, it’ll automatically set the date to the current date and link it to the exercise. You can then enter in the weights and reps for each set, one record at a time. Then when it comes time to do another exercise, you hit back a couple of times to get back to your exercise list and select a new exercise. Make sure when you link exercises to sets you tick “show inverse relationship” to create a field on the other side. This gives you the ability to go from set to exercise and if you’re using Tap Forms on the Mac, it’ll give you a small snapshot of the exercise inline (it does something similar on iOS but I think it looks cooler on the Mac).
You could use scripting to make some of this a little quicker to enter, especially on iOS, with the support of a prompter but I think this should come to you.
Pseudo-modelling it:
Workouts Form:
- Workout Name - Text
- Exercises - Link to Form (M:M): ExercisesExercises Form:
- Exercise Name - Text
- Exercise Instructions - Notes
- Sets - Link to Form (1:M): Sets
- Workouts - Link From Form (automatically created by ticking "show inverse relationship" on the Exercises Link to Form field in the Workouts form)Workout Days Form:
- Workout Date - Date (Default Value: Set Current Date)
- Sets - Link to Form (JOIN): Sets on Workout Date == Set DateSets Form:
- Set Date - Date (Default Value: Set Current Date)
- Exercise - Link From Form: Exercises (automatically created by ticking "show inverse relationship" on the Sets Link to Form field in the Exercises form)
- Weight - Number
- Reps - Number
- Date Created - Date Created (special field type; use it for sorting the Sets form)
That’s a little more complicated than I think you were expecting but that should work to model your data based on what you’ve said. You might need another form that handles the ordering for you but I think if you modelled that for use on your phone, you’d not want to use it very quickly (too many extra taps). You could reduce down the number of taps you’d need with some scripting but this should work without any scripting.
March 4, 2020 at 5:01 AM #39727In reply to: Move Column in Table View
PICOT Jean-Bernard
ParticipantYes indeed. I confirm after having discovered it by surprise today, just before your comment.
For the followers of this item, to explain again, it is NOT the form button to press (which gives access to fields and scripts and arrangement of the default form), BUT to the very little button (showing drawing of tools) on the upright of the table view (very small indeed) and give you access to possibly hide (or not) table columns and arrange their order from left to right.
Thanks for commenting.
March 3, 2020 at 11:30 PM #39720In reply to: Query to display selected records
Sam Moffatt
ParticipantOn the Link to Form field there should be a little tick icon that will let you search for existing records already in the form on the other side. On the Mac it should be under the record list and on iOS it’ll be in the top right corner when you tap into the Link to Form field. It should be there on the Link from Form field assuming it is set up as Many to Many, you might need to toggle the “Show Inverse Field” option on the Link to Form field to recreate the Link from Form field if it was created as a one to many field. A Many To Many or JOIN type should be a table on both sides (e.g. the Link to Form and Link from Form). A One to Many Link From Form will render as a single record view and if you created the inverse field before changing the type to Many to Many then it will retain that (I recall that might have been a bug that was fixed but perhaps not).
If in your user form you store a per site password then you might need a third form to store the unique passwords per site (user link from form, site link from form and password). I have some other posts on the forum about modelling such a relationship.
Internally Tap Forms store a record ID for each record and it’s backed by a document store called CouchbaseLite (which is where the CouchDB and Cloudant sync comes from). This is a semistructured data store and in a sense could be modelled as a key/value data store where the key is the document identifier and the value is a JSON document. The key exists however it’s abstracted away from the user most of the time.
CouchDB/Couchbase/CouchbaseLite doesn’t have queries in the SQL sense but instead you write a map/reduce function in Javascript. The Saved Search feature in Tap Forms is an abstraction of that interface to build the query for you. Tap Forms doesn’t expose a way of building your own map/reduce functions to power a saved search but you can do this with your own CouchDB instance.
Depending on what you’re trying to achieve, you can replicate all of your data into a CouchDB instance and get access to it there. I personally do this and have built tooling to do a bunch of different tasks. Having your own CouchDB enables full access to your data and if you follow the way Tap Forms works you can also use this interface to push data into Tap Forms.
Attachments:
You must be logged in to view attached files.March 1, 2020 at 6:26 AM #39694Topic: Reading Hardware-UUID with Java Script
in forum Using Tap Forms 5Chris Ju
ParticipantHello,
does anyone have the programming code in java script for reading the Hardware-UUID?
Terminal command from stackflow:
ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }'I want Tap Forms to read the Hardware-UUID and write it to a field on every change of an entry. The next step could be to add a log entry (in a log form) for changes … on every change a new entry in the log form will be generated (one time calculation)…
Thanks a lot
ChrisFebruary 29, 2020 at 12:32 PM #39690Brendan
Keymaster@Max, I can answer your UPC data from Internet question by pointing you to the code snippet on the Scripts manual page under the topic “Fetch Movie Data from Web Service”.
https://www.tapforms.com/help-mac/5.3/en/topic/scripts
There’s sample code there that shows how to fetch data from the Internet given a barcode.
February 29, 2020 at 11:34 AM #39688Max Heart
ParticipantThanks a million, Sam. I will download the files and will give you feedback asap.
EDIT: It works. Amazing. I will now try to transfer your script and adapt it to my forms which are relatively similar.
Just a curious side question, slightly OT: You have UPC as one field. Would it be possible to pull item data from the internet automatically by using the UPC?
February 28, 2020 at 7:39 PM #39680Sam Moffatt
ParticipantOk! I did some work to set up a sample document with the scripts in it. There were some modifications to the original ones I posted, this edition doesn’t prompt to confirm the item name, it has support for automatically creating new records and it prompts if you try to reassign an item from one box to another if you want to do it.
I’ve attached three files:
- Boxes-20200228.tfarc: a Tap Forms archive containing all of the forms with some sample data.
- Boxes-20200228.tff: a Tap Forms Form Template with the box forms.
- Script Manager-20200228.tff: a Tap Forms Form Template with the Script Manager including an updated set of form scripts.
Took a bit of time to put this all together and test that it works roughly the way I’d expect. It includes two Link to Form fields, one set up as a 1:M type and another set up with a JOIN type. The “Bulk Add to Form” script will handle updating the 1:M field properly and the text field referred to by the JOIN type.
Right now it’s a little chatty, you might want to tune that down a little or bypass some of the confirmation items.
Let me know if that helps a little more with figuring things out. If it makes sense, I might put it up on the template exchange as well.
Attachments:
You must be logged in to view attached files.February 28, 2020 at 11:46 AM #39677In reply to: retrieving apple health data (via Shortcuts?)
Brendan
KeymasterHi Guillaume,
Those two shortcut actions were accidentally left in there. I’ve removed them for the next update. I tried to make them work, but because of the dynamic nature of Tap Forms, I couldn’t get it to ask you for values for the fields, so I couldn’t make that work. At least not until Apple enhances Shortcuts to allow dynamically assignable parameters. So right now the only shortcut that works is the one for running form scripts.
But it might be interesting to integrate Tap Forms directly with HealthKit so you could import all your HealthKit data into Tap Forms. I workout every day myself and use the Activity app to view my health data. So it would benefit a lot of people I think. I’ll think about it.
Thanks,
Brendan
February 26, 2020 at 4:22 PM #39658In reply to: Copying text from link-to-forms fields
Sam Moffatt
ParticipantI wrote a script a while back to combine multiple values from Link to Form field for precisely the reason of being able to search for those records. You can just have the script field contain the data and it’ll show up in search, it’s exactly how I use it. I use them on Table fields in some places as well to help roll up aggregates.
February 26, 2020 at 1:39 PM #39656Topic: Copying text from link-to-forms fields
in forum Script TalkEdu Neve
ParticipantHello,
I have zero experience with Javascript and I’m struggling to understand the provided documentation regarding scripts. The reason I’m considering scripts is because I really want to be able to search and sort fields that link to other forms, but from what I’ve read in the forums this is unfortunately not possible yet (this is absolutely my number one request for future development).So, I figured an alternative would be to create a script that copies the contents of a field that links to another form, into a regular field. This way, when I sort or create saved searches/filters, I can point to the regular field that would have copied the relevant contents.
So, all I want is a simple automated copy-paste of the text or numeric contents of a field (that links to other forms) into another field of my form. I haven’t been able to find a step by step guide in the documentation or in the forums.
I see that I’d use “get field value” and “set field value” or “set multiple field values”, but I don’t know how to go about it. Do I create the script as a field, or do I simply add it to the Scripts pane? And once I create the script, what would I type there?
Any help would be much appreciated. Thank you.
February 26, 2020 at 11:57 AM #39655Max Heart
ParticipantOMG, Sam, I feel so bad and like a complete idiot … I appreciate your help so much but I am not able to translate it to my database.
If you still have patience to advise I would highly appreciate it. I will try to describe precisely where I am:
– I have two forms: “Inventar-Boxen” which has all the boxes and “Inventar-Inhalte” which has all the individual items. The field “Inhalte” in Inventar-Boxen is linked as one to many to the form Inventar-Inhalte. “Show reverse link” is enabled
– The form “Inventar-Boxen” has the following fields: “Boxname” (Calc Field: Box number, box name, box type), Place, box number, box type, contents (“Inhalte”: the linked field), Barcode (the QR code field – a calc field “Box+box number”)
– The form “Inventar-Inhalte” has “Foto”, “Item” (Calc Field: Manufacturer + item name), Boxen (re-link from the “Inventar-Boxen” form), “Barcode-ID” (this is the bar code identifier), “category”, “label”, “notes”, “invoice”, “purchase date”, …What I did:
– I created the script manager form and copy pasted your “Prompter functions”
– I copy pasted your second script into the script section of “Inventar-Boxen” and named it “Bulk Add”. I assigned Alt+Cmd+Y as a keyboard short cut.
– I tried to exchange your fields with mine. However, I am already lost with the field IDsIs there a chance to have a look at your tap forms file with just one set of sample data? Maybe I would be able to understand the scripting concept better then.
Again thank you very much and best regards, Max
–February 25, 2020 at 3:43 PM #39652Sam Moffatt
ParticipantSo for the second script, I have two forms, one is “Boxes” which stores the details about the physical box and then I have another form for “Purchases”. “Purchases” was the name of my original Bento library from what feels like a decade ago now and was mostly flat and denormalised. As I’ve gone along I’ve started to normalise everything but it’s all over the place. I had added ages ago “Bag Barcode” and “Storage Box” to the “Purchases” form but didn’t really do much with them. When I started moving, I decided I wanted to have a first class ‘Boxes’ form.
The ‘Boxes’ form looks like this:
Boxes: (frm-8ba92c77b5e8476a987945f40ff2b41a) 'Title' text (fld-e289240daccc40409d75aee26493110c) 'Box ID' text (fld-f25492cf56384369b278f7ea41ee258f) 'Note' note (fld-69754dee7e9247e0b3087e2526881626) 'Dimensions' text (fld-3e5e30f1d352495f989cc0dc1b306128) 'Box Type' text (fld-97b2ab2bdbb1400d9384c7634e7c6d48) 'Box Photos' photo (fld-72a520cff50a4bbd92f1e8ff6eec91db) 'Purchases' form (fld-482c4f5c71ba4cd7a06c32d1c1d7d983) join 'Purchases' (frm-efc0199a2b1543f79e722383014533b0) ON Boxes.Box ID == Purchases.Storage Box 'Containing Box' text (fld-fe868108cdd844d895ea982e820b346c) 'Boxes' form (fld-74466a4b96dc43b4bcbe153646b76911) join 'Boxes' (frm-8ba92c77b5e8476a987945f40ff2b41a) ON Boxes.Box ID == Boxes.Containing Box 'Tracking Number' text (fld-54af5c1e20e14d20a7c82a40679a2a8a)It has some metadata about the box such as a title, it’s
Box ID(which maps to thebox_id_idvariable) which is the unique identifier tied to the barcode, it has some other details that are useful and then it has a link to my existing ‘Purchases’ form. There is a ‘Link to Form’ as “JOIN” field here to tie the box record to the purchases record. I also have an extra field for when this box is inside of another box plus a ‘Link to Form’ self-JOIN field. Since some of these boxes are being shipped, they are also tied to a tracking number (I should probably have made this a link to the shipments form I have in this document but didn’t).My Purchases form looks a little bit like this, I’m going to cut out some fields because it has 121 individual fields in it that aren’t particularly relevant. Here are the first few.
Purchases: (frm-efc0199a2b1543f79e722383014533b0) 'Image 01' photo (fld-e631165b67374734a3b8f384708b5922) 'Title' text (fld-0d0edd2552ea461e929f806a4e5552b5) 'Subtitle' calc (fld-45ef928f87e24bcd93e6751c8c21a6cb) Referenced Fields: - State (fld-9402f8c0d53c43b986fee4ebc3468929) - Colour (fld-a8626656cc90455ea9336dd2488d4aef) - Category (fld-6fdd09891a8c4d73be1b24aa07d077be) === 'State Details' section (fld-21cdfa78aaf44d3b83e5c0e16c8d40d1) === 'State' text (fld-9402f8c0d53c43b986fee4ebc3468929) 'Previous State' text (fld-636a7a4671c14877b1b17ea1b579cef5) 'State Watcher' script (fld-45463af0b409465ea78ad7c498ee896d) 'Colour' text (fld-a8626656cc90455ea9336dd2488d4aef) 'Category' text (fld-6fdd09891a8c4d73be1b24aa07d077be) === 'Main' section (fld-76597ce17f924c25bbcb195df984331c) === 'Date Created' date_created (fld-0d049abe706b41afb680ab9a1bf99d46) 'Date Modified' date_modified (fld-59a06347614e48e8bf547a855b781582) 'Purchase Date' date (fld-ccbd9a8f51d34246bebfb31aa4e397dd) 'Ship Date' date (fld-cb3a9886ac7f4ec487447801a3911a1a) 'Received Date' date (fld-bb17d48e41c7423692ab586f6c884d05) 'Order ID' text (fld-e3e66a0f2e5c4df7b9496f65355e0bcf) 'Marketplace' text (fld-c163aba17ae64c4d93b5a53819a139dc) 'Store Name' text (fld-3d98dc6cdcae4a88909c97c80dde7bfb) 'Brand' text (fld-1e250019d7b249f282cc572814d3e71d) 'Source' web_site (fld-da9d866bf3ca4d47aade04a77efd7301) 'Source Scraped?' check_mark (fld-a0557d4c58334bbc81b356b99f6f0a1d) 'Source Scraper Script' script (fld-429e3e7ca20a49d38b26417e25e6db26) 'Item Key' text (fld-ae7379d699e9473aa2ab16a2a2f002d4) 'Price' number (fld-08129d71ab0f4fa4a2749456281fca07) 'Shipping Tracking Number' text (fld-6ea45a9c141343628940bfbcfa38ee90) 'Shipping Carrier' text (fld-12644a7a4ae24ed8a7926123832d3557) === 'Storage' section (fld-f99f779335f54b9cb0a4179a90bb97dd) === 'Bag Barcode' text (fld-32d459f0b5fb4dc4974795c484832af1) 'Storage Box' text (fld-c08e3a9eb7784d7f8ee3a5576c0adffa)Reasonably generic listing of fields for an object you’d buy, again it’s a little flat because of how I modelled it in Bento but you can see at the end in the storage section the two fields: ‘Bag Barcode’ (which maps to the
bag_barcode_idfield) and ‘Storage Box’ (which maps to thestorage_box_idfield). These are simple text fields that have the unique barcode for the bag storing the item as ‘Bag Barcode’ and then ‘Storage Box’ is the barcode of the box that this item is currently contained in.February 25, 2020 at 2:03 PM #39650Max Heart
ParticipantHi Sam,
thank you so much for your two long posts with explanations. I will try to understand them and modify the variables so that they fit to my forms.
So far
– I imported your Script Manager form
– I added the Prompter script to the Script Manager form
– I created a script field in my box form and pasted your full script from the second post
(… and I bought a barcode scanner for my Mac)Now I have to understand and adapt the script. The field which contains my QR code of the box is called “Barcode”. Is this field called “box_id_id” in your script?
February 25, 2020 at 6:51 AM #39649In reply to: Tracking Subscriptions (cost, renewal date, etc)
jolinwarren
ParticipantTJ, I just read your blog post on Bobby (an app which I installed a few years ago and then never used), and after reading about its limitations, thought, “I should set up a Tap Forms database to track my subscriptions instead”. Your blog post helped clarify in my mind what I would want to track for subscriptions, and why (which match yours). I’ve been using Tap Forms for many years, so it’s the place I would naturally want to do this. I headed over to the forums here to look into a couple of things and came across your post, a nice little circle!
However, you would probably need a couple of fields to store the subscription costs based on whether they’re annual fees or monthly fees. Because Tap Forms wouldn’t be able to detect if you typed in “$2/month” or “$24/year”.
I was thinking of handling this a different way, basically having a ‘price’ currency field and then a tickbox for “annual” (default being monthly for me, but you could reverse that). Or there could be a choice field if weekly, biannual, or other frequencies need to be supported. Then I would have two calculation fields, “monthly cost” and “annual cost”, and using the price and tickbox fields, it would be possible to calculate and display both.
I haven’t built anything yet, but I’m happy to share it when I do if you’re still interested.
Cheers,
Jolin -
AuthorSearch Results