Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
August 13, 2019 at 6:51 PM #36321
In reply to: Need an example code to SUM checkboxes
Brendan
KeymasterHi Karl,
Thanks for the file. I’ve just had a chance to look at it with your formulas.
However, I’m not sure what you mean by this:
The four “Over-15” checked checkboxes would be noted and the first four of the first set of checkboxes would then be checked. I would love to be able to automate these two functions with a script.
Here’s a script that’ll reset the checkmarks for the first 15:
function Reset_Checkmarks_1_15() { var f1_id = 'fld-66cc9d4ad3c149c496cd3be90ea0f88c'; var f2_id = 'fld-0dca226557ba47d2b806dd2f20d955ec'; var f3_id = 'fld-e084b0d50e104044ab8baf2df11ae1e4'; var f4_id = 'fld-6ee4490027334c8ea99f9e0365fef5f7'; var f5_id = 'fld-b31757d2bda64dbfadf5fa3569857c33'; var f6_id = 'fld-fbb171c0d7c14d90b5a248ea6baab1a9'; var f7_id = 'fld-43a5c0ff16694eb19325b9c24dcaa2de'; var f8_id = 'fld-4f1cbec2e2bd475b8a58badd20e66826'; var f9_id = 'fld-9985de5176ac4861890a245c729e818a'; var f10_id = 'fld-c5cf49dd9e954f18952e0eb7354f93aa'; var f11_id = 'fld-49c502ea885342738df3ce1958d0542e'; var f12_id = 'fld-22395b52e8a344e8b23499df65def764'; var f13_id = 'fld-07b05a9ad759465abd4ffc436e74b11e'; var f14_id = 'fld-6be47e6efbee473b9a725e67167dd90c'; var f15_id = 'fld-d507eb4e113d4380b1ab5f2f20518e6c'; record.setFieldValue(f1_id, 0); record.setFieldValue(f2_id, 0); record.setFieldValue(f3_id, 0); record.setFieldValue(f4_id, 0); record.setFieldValue(f5_id, 0); record.setFieldValue(f6_id, 0); record.setFieldValue(f7_id, 0); record.setFieldValue(f8_id, 0); record.setFieldValue(f9_id, 0); record.setFieldValue(f10_id, 0); record.setFieldValue(f11_id, 0); record.setFieldValue(f12_id, 0); record.setFieldValue(f13_id, 0); record.setFieldValue(f14_id, 0); record.setFieldValue(f15_id, 0); form.saveAllChanges(); } Reset_Checkmarks_1_15();
August 13, 2019 at 1:53 AM #36315In reply to: Need an example code to SUM checkboxes
Brendan
KeymasterHi Karl,
When you export records, if you use the Tap Forms Archive format, Tap Forms will export the form template along with all the records. That’s a more complete way of sending someone your database.
It’s also handy for copying a form and all its records from one document to another or to give to another user.
So in this case, your template with any Calculation or Script fields did not come across.
I’m working on some access controls code for the next update to Tap Forms which would allow you to specify for a specific form what a user of that form could do. E.g. edit form, add records, delete records, update records, etc. It’s not ready yet and so far it’s just on macOS, but I will bring it over to iOS once I’ve got the Mac version complete.
August 12, 2019 at 9:58 PM #36310In reply to: Need an example code to SUM checkboxes
Karl M. Rowe
ParticipantHi, Brenden!
Thanks for posting replies to my post. I’ve learned a little more about what this database is capable of doing.
Attached to this post is a .CSV file (Loyalty15.csv), which is just a copy of my database, which contains three scratch records. In my original are two sets of checkboxes, the first set of 15 and the second set of 10. What you will see when it is imported are 15 text fields and 10 text fields, respectively. I don’t know if the “Checkbox” field type can be retained after the exporting and importing of the database, but I had to change the field type after importing it afresh into the app.
I used your idea to make a Calculation field to sum the first set of checkboxes; if the first Calculation field equals 15, then the second Calculation field becomes “YES.” If not, the second Calculation field remains “NO.”
I used an additional Calculation field to sum the second set of checkboxes; “Over-15” contains the total number of checked checkboxes.
To explain, customers are rewarded with a free item for every 15 items purchased. If anyone purchases 19 items, for example, there will be a “Yes” and “4.” A search reveals the number or records in which all of the first set of checkboxes have been checked; these records are recorded elsewhere, and all 15 of these checkboxes would then be reset. The four “Over-15” checked checkboxes would be noted and the first four of the first set of checkboxes would then be checked. I would love to be able to automate these two functions with a script.
There’s room for improvement and any suggestions that you and others here might have to improve this database would really be appreciated. I did wonder if it was possible to line up both sets of checkboxes horizontally, instead of as they are now, vertically; if this is possible, I would appreciate your pointing out to me a web page containing the steps required to do this.
Lastly, I wondered if there was a way to secure the database, to make it impossible for users without a password (or permissions) to delete records; they could add records, run searches, but not delete any of them. How might I accomplish this using my iPad? Thanks.
Peace
August 12, 2019 at 9:10 PM #36309In reply to: Need an example code to SUM checkboxes
Karl M. Rowe
ParticipantHi, Sam!
I appreciate your pointing out to me how I might use a script with my database to reset a set of checkboxes. I’d like to see a few examples of how such might be used. An example of an “Are you sure (y/n)?” prompt using Javascript is something I’d also be interested in seeing. Thanks for your reply.
Peace
August 10, 2019 at 8:11 PM #36289In reply to: Anyone here that can build a database for pay?
D J Leason
Participant@ Sam Moffat
# How to handle log entry?
Immediate thought was to use a script to create a new child entry that copies the calculation field you have but part of me wonders if you’re thinking about this the wrong way in that this is already your daily log! Just add the records per day and you’ve got your log (duplicate if that makes sense).That log entry is for the weight to volume method only, which I don’t use daily. I can see the entry in the Form where created in the MCLV so that does give me a chronological list of tinctures made using the W2V method. I can see the entry in [Herb] Form / [WIP_W2VC Link to Form table], which gives me a list of each time I started that particular herbal tincture using that particular method but it does not show in the MCVL there because it’s just a [Link to Form] field and for the same reason, I can’t drag it into a new layout. So to get a chronologically ordered list for the year, although admittedly less expedient, I can physically copy and paste each entry to the [Daily Herb Log Form], (I haven’t advanced to Scripts or child entries quite yet), which helps me plan my calendar for next year. I could have a [Herb Log Entry] calculation for each Form with activities, copying and pasting each until I learn how to write scripts. Is that what you mean by duplicate? I really do appreciate all your help!
August 10, 2019 at 4:03 PM #36288In reply to: Design advice requested
Sam Moffatt
ParticipantTapForms doesn’t cascade deletes out of the box if I remember correctly. There’s some nuance in the Link to Form on if it “Deletes” or “Unlinks” for removing child records manually but if you delete a parent record, I don’t think it cascades those changes.
You could use a form script to do a cascading delete function, most of the time I’m adding records and very rarely delete them so it’s not a problem personally I have.
August 9, 2019 at 5:39 PM #36272In reply to: Need an example code to SUM checkboxes
Sam Moffatt
ParticipantYou could make a form script and just reset the field values when it runs:
record.setFieldValue(cbo1_id, 0); record.setFieldValue(cbo2_id, 0); record.setFieldValue(cbo3_id, 0);
Replace cbo1_id, cbo2_id and cbo3_id with the field ID’s of each of the checkboxes up to your 15, the script editor will insert some boilerplate for you if you double click the field names.
You can bind a shortcut to the form script to make it easier to execute. It’s also available via the “Scripts” menu item and of course via the Scripts tab to the right of Fields on the Forms panel on the right hand side.
You could also create a field script based on the value of another checkbox but form script is a little more implicit in my mind. You can also put an “are you sure” prompt into your form script for extra safety, check out the prompter section of the JavaScript API.
August 9, 2019 at 3:31 PM #36269Topic: Forum Summary Problem?
in forum Script TalkDave Emme
ParticipantIs it just me?
I’m seeing the “Freshness” value for the Script Talk Forum to be “1 week ago”, by “sdd qwd”. But I can’t find any such post inside the Forum. The most recent topic displayed is “For Help” by “talal alotaibi” dated “1 week, 3 days ago”. And there’s no “sdd qwd” post in it.
This has been going on for about a week.
August 9, 2019 at 3:20 PM #36268In reply to: Text Field Behavior
Dave Emme
ParticipantPick List on a Note field “seems odd”? Please explain. I gave my real-world example in my previous post (which worked just fine in the legacy iOS app I migrated to TapForms from). Please tell me (really) what you think is “odd” about it. Or is there a different approach I should be taking to accomplish my stated “requirement”?
As for “Display As” etc., I’m afraid you’re talking over my beginner level of experience with your app here. But they sound like things that the Plain Text Note option might allow a resolution for(?)
Note that when my script copies the several chosen Pick List values from the Text field to the Note field, they come over as comma-separated strings. And I’m perfectly ok with that.
On the other hand, it is your app. Maybe I should just be satisfied with my working kludge.
August 9, 2019 at 12:39 AM #36261In reply to: Need an example code to SUM checkboxes
Brendan
KeymasterHi Karl,
I haven’t exposed the Hide Field function to the Script engine yet.
It wouldn’t work with the Calculation field type anyway as a Calculation field cannot modify anything outside of returning a result of evaluating the formula.
So at the moment there’s no function to do this. But I’m working on exposing more field level properties to the Script engine as I receive customer requests for them.
Thanks,
Brendan
August 8, 2019 at 11:54 PM #36260In reply to: Anyone here that can build a database for pay?
Sam Moffatt
Participant“Right” is subjective to be honest, again I’d take an iterative approach. Import everything as is and then start to add functionality from there. Seems like you’re already well into that approach so that’s cool. One observation is possibly that “Others Herbs” and “Herbs” should probably be one form eventually and just have a checkbox for “Other Herbs” then filter out.
# How do I add 1 to ratio b and update the other calculation?
Calculations are fun but calculations are executed in order and grab the value of a field when they execute. Scripts used to run before calcs but now I think they run afterwards so what might work is to use a script field as it’s always at the end.
There is also a refresh button at the bottom that will trigger everything to refresh. Assuming your calcs are stable then hitting refresh will ensure everything is up to date.
A hack you can do with script fields is to reference the field but not use it. That causes the script field to run but they don’t inherently need to care about the field itself.
# How to handle log entry?
Immediate thought was to use a script to create a new child entry that copies the calculation field you have but part of me wonders if you’re thinking about this the wrong way in that this is already your daily log! Just add the records per day and you’ve got your log (duplicate if that makes sense).
# How many forms?
Conceptually what you’re aiming to do is not duplicate where possible. If you have a field value that exists in two places and is always the same, then it’s a candidate to be it’s own form that you link to from multiple places. That’s an ideal state, the path there from here is a little harder. You can start by using Link to Form with JOIN type to link stuff together and slowly add in the other types.
If all of the data is unique to that form and not repeated else where, make a mega form. The linking generally wants you to go 1:M or M:M so I’d think of it that way too: if there is only ever one value then leave it on the same form, if there are multiple potential values then create a new form and link to it or maybe use a table.
Fundamentally try out how it works for you and slowly move stuff around. And as always make backups.
August 8, 2019 at 3:17 PM #36255In reply to: Text Field Behavior
Dave Emme
ParticipantOk, here’s what I’m trying to accomplish: a field which will hold more than, say, 256 characters, which can have text entered via something like a Pick List (for consistency), and which will also allow me to supplement any Pick List entries by typing arbitrary text, either at initial creation or later. Plain text is acceptable – indeed, desirable. E.g. a Note field with an attached Pick List.
But I currently can’t have that, so I got to probing the limits of a Text field, which prompted my original post, and what I considered anomalous behavior from the Text field. E.g. why does it behave differently on different devices? It does not follow the Programer’s Law of Least Astonishment. :-)
Perhaps a Pick List attribute could be implemented on Note fields, but only enabled if the field’s Plain Text Note attribute is enabled?
My current workaround is to have (1) a Note field to contain the complete desired text value for the record, including any manually-entered text, (2) a Text field with attached Pick List to allow choice of predefined value(s), and (3) a script to automagically copy the contents of the Text field into the Note field whenever the former changes. It works, but certainly is far from elegant (why does he have these two “text” fields with nearly the same contents?), and would not even be possible for a user without scripting abilities.
All I really need is (1′) a Note field with a Pick List.
August 5, 2019 at 11:19 AM #36213In reply to: Bug in iOS
Brendan
KeymasterI’m not sure how this is related to setting values via a script. Because setting values via a script would completely bypass the operation of the Pick List Select Values screen.
August 5, 2019 at 9:15 AM #36211In reply to: Bug in iOS
JBB
ParticipantBrendan, FYI, this happens on iOS whether you try to set the values manually or via a script. Thank you.
July 31, 2019 at 12:27 AM #36129In reply to: Export single record?
Sam Moffatt
ParticipantIt’s not the most elegant but if you do a search/filter first, when you export it will only export the records returned by the search. I only tested this on Mac, not iOS.
You can record a Siri Shortcut and hook it up to a script that creates new records for you in Tap Forms. You can’t get any input into it, it’s a very basic integration, but it will let you create a new record.
It takes a lot more effort but you can also directly create records in CouchDB via the Shortcuts app which is the other way I create new records. I use this to prompt for some text, gather the current location and then use that to add new entries to my document.
-
AuthorSearch Results