Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
May 25, 2019 at 5:59 PM #34950
In reply to: Scripting – get value from other form
Anonymous
InactiveHi Sam, thanks for the info i’ll try it soon.
I’ve got a Numbers sheet with customer data comprised of names, mail, website, where it hosted, prices etc.
Got most customer fields already in 1 form and prices etc are calculated correctly through scripts. Now I want to make an overview form which show me total prices, average monthly income / expenses, how many websites are hosted with a specific holster etc.
As an example I asked the question because I want to have an overview how many sites are hosted with hosting provider x, y and z. Can’t do that with an calculation (Numbers got an COUNTIFS, tapforms not) and calculations are not updating in my case so I’m using the script function (also gives me more advanced features and also easier for me to understand as a coder)
May 25, 2019 at 11:49 AM #34947In reply to: Scripting – get value from other form
Sam Moffatt
ParticipantYou need to do a loop for that:
var customers = record.getFieldValue('fld-a538b0e58afa4d5db40dd06a19af2436'); for (var index = 0, count = customers.length; index < count; index++) { var name = customers[index].getFieldValue('fld-c4e6710f99544905b9cbbf1fcbd8f613'); name; }That will overwrite if you have more than one field linked.
The Script Editor will only display the fields from linked forms however you can copy and paste the field ID’s and keep track of them manually. Linking makes it a little easier but the ID’s in the script itself is unrelated to any links. You can use
documents.getFormNamed('Customers').getRecords()to get all of the records in that form instead of usingrecord.getFieldValue.Do you mind sharing a little about your use case and the problem you’re trying to solve?
May 25, 2019 at 11:42 AM #34945In reply to: Booking Form/ Leads Form/CRM – Relationships?
Sam Moffatt
ParticipantI use a script in one form to create a new record in another form. On Mac if you create a form script, you can create a new record based on the currently selected record. This creates a copy of the data, not a reference, so if it changes in one place it doesn’t change the other which may or may not be problematic for you.
You can do it a couple of ways, you can get the form from the document and create a new record (
var newRecord = document.getFormNamed("Bookings").addNewRecord()) or if you create a Link To Form from your Leads form to your Bookings for you can add a new record via (var newRecord = record.addNewRecordToField(link_field_id)).Then with that newRecord you basically map across the fields from the two forms to update them.
Here’s an example using the
addNewRecordToFieldapproach that I use. It’s slightly simplified example but basically it gets all of the values from the record, adds them to a dictionary and then uses that to save the data to the new record. For what you’re doing this might be useful because you can see which leads lead to the booking.// Pull some details from this record var title = record.getFieldValue('fld-39ca9564ef2347ac93f933bc9a2316ac'); var price = record.getFieldValue('fld-a2973999a60d4319baf0b4480d6f57a0'); var note = record.getFieldValue('fld-d0cfab9ec09d497294fbd8b5b52caf16'); var line_number = record.getFieldValue('fld-f95b68d488cb4b058bbf3de84e1a7c3b'); var purchase_date = record.getFieldValue('fld-bc2e4b152dee42ac9361539a6e37cb5d'); var marketplace = record.getFieldValue('fld-fa37906add2942c88bce3b500561c42d'); var order_id = record.getFieldValue('fld-8228040b4641449b96aabfaea15f1ac5'); var store_name = record.getFieldValue('fld-c153da2f9a504be4b6fee4b5b62a1c11'); var ship_date = record.getFieldValue('fld-6ab700ccc11d418fbd27d8899d00c7a9'); var delivery_date = record.getFieldValue('fld-4b1c4180dc1b4bb08b32d16fa60cae66'); var purchase_key = record.getFieldValue('fld-3e49aaa5bc32429c8f0f0f234878356d'); // Details field names var details_title_id = 'fld-0d0edd2552ea461e929f806a4e5552b5'; var details_price_id = 'fld-08129d71ab0f4fa4a2749456281fca07'; var details_notes_id = 'fld-bf19d52c18cb4f5198df191ef7902e1b'; var details_purchase_date_id = 'fld-ccbd9a8f51d34246bebfb31aa4e397dd'; var details_ship_date_id = 'fld-cb3a9886ac7f4ec487447801a3911a1a'; var details_received_date_id = 'fld-bb17d48e41c7423692ab586f6c884d05'; var details_order_id_id = 'fld-e3e66a0f2e5c4df7b9496f65355e0bcf'; var details_marketplace_id = 'fld-c163aba17ae64c4d93b5a53819a139dc'; var details_store_name_id = 'fld-3d98dc6cdcae4a88909c97c80dde7bfb'; var details_state_id = 'fld-9402f8c0d53c43b986fee4ebc3468929'; var details_shipping_tracking_number_id = 'fld-6ea45a9c141343628940bfbcfa38ee90'; var details_shipping_carrier_id = 'fld-12644a7a4ae24ed8a7926123832d3557'; var details_purchase_key_id = 'fld-8be9b2c2603f458f8349082237c41964'; var details_order_line_number_id = 'fld-da763fa0946d4be79039b4e828cf85f4'; var data = { // Order Item Details [details_title_id]: title, [details_price_id]: price, [details_notes_id]: note, [details_order_line_number_id]: line_number, // Order Details [details_purchase_date_id]: purchase_date, [details_ship_date_id]: ship_date, [details_received_date_id]: delivery_date, [details_order_id_id]: order_id, [details_marketplace_id]: marketplace, [details_store_name_id]: store_name, [details_purchase_key_id]: purchase_key, }; // Last but not least push the new record. var details_id = 'fld-ac04de32d98242b88333977c89526fc1'; var detailsRecord = record.addNewRecordToField(details_id); detailsRecord.setFieldValues(data); document.saveAllChanges();One of the advantages of the script approach for me is that it let’s me splice in extra data or set new values at creation time as well. Another trick I do is use a form script to use a prompter to ask for extra data and integrate that into my new record.
Scripting manual section: https://www.tapforms.com/help-mac/5.3/en/topic/scripts
May 23, 2019 at 12:35 AM #34933Topic: Scripting – get value from other form
in forum Using Tap Forms 5Kana Ne
ParticipantIs it possible to get the value from a field on an other form in a script?
I can’t see the fields from another form in the script window of this form.Thanks,
KanaMay 10, 2019 at 6:53 PM #34721In reply to: script acting on selected records?
Brendan
KeymasterYou can create a Saved Search to filter your records, and then have a Script run against just the found set. But not on arbitrarily selected records.
May 10, 2019 at 7:15 AM #34718Topic: script acting on selected records?
in forum Using Tap Forms 5Bert Rietveld
ParticipantIs it possible to have a script acting on (a few) selected records rather than all or one?
I’d like to use that for a ‘merge records’ script. The map view is great for seeing that a couple of records are for the same (or close) location even when they have (slightly) different names. I could then select them and merge those records.May 9, 2019 at 2:51 PM #34708In reply to: Labels With A Header/Footer
Stephen Martin
ParticipantThanks, Brendan.
P1) I have to meet a form design, so the list mode (Table of Records) won’t work for me.
P2) I had not figured out what the parent/child relationship and capabilities were, so you’re description answered my question. Thanks.
The only way I can get to my need then, is to use pre-printed forms with the headers; then print the labels layout or vice-versa. Thx.
May 8, 2019 at 8:34 AM #34685Topic: JS creating folders on disk with data
in forum Using Tap Forms 5Gilles Cruypenynck
ParticipantHi,
Would Javascript (used within Tapforms) allow me to create folders on disk named after some data from Tapforms?
Think, for example, of a students database and creating folders named based on their family name field.I don’t know JS and thus whether I should spend/waste time trying to write such a script.
Any help or advice will be much welcome.
Regards
Gilles
May 6, 2019 at 1:46 AM #34655Topic: Searchable Bullet Journal Index
in forum Tap Forms Template ExchangeKimberley Hoffman
ParticipantI created this so I can search my bullet journal for important entries. For some reason the background (the dotted ‘paper’) didn’t export correctly with the file, so I’ve added it to my zip-file.
It contains entries for your bujo number, for when you started and finished the bujo, a photo drop for your index pages and highlights as well as file drops for your calendar and future logs, which you can change to a photo drop before beginning your entries.
For the headlines I’ve used a free font Blenda script and a pay font – Blend script – for the date entries. But you can use any font on your system.
I hope you enjoy it!
Regards,
KimberleyAttachments:
You must be logged in to view attached files.April 26, 2019 at 7:48 PM #34571In reply to: Calculation fields in tables
Brendan
KeymasterYou can already reference parent fields in a Calculation field or Script field if you’re using a Link to Form field.
You need to enable the Show Inverse Relationship option on a Link to Form field to get that though.
But you’re talking about a Table field. I haven’t enabled access to parent fields in a Table field. I think you’re the first one to ask for it. I’ll think about it for a future update to see if it’s possible given my current architecture.
But to me it sounds like you want to go the other way. From parent to child. So if you change the number of servings in the recipe, you want the quantities of the records in the Table field to update accordingly. You can already do that with a Script field on the parent form. The Script field could be triggered to run whenever the value in the Servings field changes. It would loop through all the child records in the Table field and update the quantities. I’m assuming it would just multiply the new serving size by the quantity in the ingredient.
There’s a Snippet on the Script Editor that’ll loop through all the child records.
April 19, 2019 at 12:52 AM #34448In reply to: Text Fields Right Aligning Unexpectedly
Barry Shevlin
ParticipantThank you, Brendan. The downside to that, of course, is that with the show edit/save button off, all empty fields are displayed.
The text alignment issue seems spurious: only some of the text fields, on some of the records, some of the time. And once re-aligned (left), they don’t necessarily stay realigned!
I’m more than happy to not have the edit button but not so happy to have empty fields displayed.Is there a way of having my cake and eating it? A script perhaps that hides empty fields?April 16, 2019 at 9:33 PM #34426In reply to: V5.3 Manual
Brendan
KeymasterModifying a child record should trigger a parent record’s Script field to run. But ya, it seems that just adding a record does not seem to trigger the parent record’s scripts to run. Deleting a child record and modifying a child record does though. I’ve just worked on a fix for that.
April 16, 2019 at 12:42 PM #34423In reply to: V5.3 Manual
Dave Emme
ParticipantOK, great! That helped a lot; thanks.
Now I have one more question (or feature request?):
I have a database of phone calls, with a parent form “Callers” and a child form “Calls”, linked via the phone number. Callers has a join to Calls, to display a nice table of related calls in the Callers record.
What I’m trying to do is extract the number of call records and the date of the last call from the related Calls form records and place those values in fields in the related Callers form record.
I have a script field in Callers with a script which extracts the wanted values and inserts them in the Caller record. The script works fine. Per your info above, I can automatically trigger the script by referring it to a changed field in the Callers record, but apparently only a “real” data field in Callers. What I would like is to have the script run automatically when I add a Call record, by clicking on the “+” in the Calls table joined to the Callers record. But if I try to make my script trigger on changes to that join field, nothing happens, even though it has effectively changed. So I have to manually trigger this script by making a change to a “real” field in the Callers record after adding the new Calls record.
Is there something equivalent to an “event” which will run my script when I add a record to the related Calls form/table? (Maybe this is something I should know, but I’m not (yet) a JavaScript programmer)
Thanks for your help!
April 15, 2019 at 9:33 PM #34420In reply to: V5.3 Manual
Brendan
KeymasterHi Dave,
The Script Editor on the iOS version was built tased upon the Calculation field’s formula editor. If you’re familiar with writing formulas in Tap Forms then hopefully that’ll translate over to using the Script Editor.
When you tap on the script to edit it, a toolbar appears above the keyboard. Tapping on the
fxbutton is how you access the Snippets, which are the little bits of code that Tap Forms writes for you to do different things. Thefieldbutton just to the right of thefxbutton is where you access the list of fields. Tapping on a field will insert the appropriate code into the script. You can have Tap Forms generate therecord.getFieldValue()function for you or just generate thevar field_name = 'fld-1234....';code for you.I’ve also updated the manual to describe a bit about the “magic” that triggers a Script field to execute. Basically any reference to
record.getFieldValue(field_id)in the script will tell Tap Forms to start monitoring the referenced field for changes. If you edit the field value in a record, Tap Forms will look to see if any scripts are referencing that field. If so, it will then execute the script within that Script field.Form level scripts are executed manually by you. You do that from the action menu button on the records list view by tapping on Run Script and choosing the script to run. You can also edit scripts from there too.
Hope that helps you a bit more.
Thanks!
Brendan
April 15, 2019 at 3:45 PM #34419In reply to: V5.3 Manual
Dave Emme
ParticipantBrendon said:
There’s no manual for the iOS version, but the Mac manual has many of the same concepts.Well, “concepts” yes, but that’s not sufficient. I’m currently trying to work with scripts on iOS, and the Mac manual refers to objects such as menus which don’t seem to exist as such in the iOS version. For example, I still can’t figure out Form scripts vs script fields in records.
And in any case, the gears and levers of scripts are still opaque to me. For example, the scripts chapter in the Mac manual gives an example of a Movie DB script which runs automatically when barcode information is entered into a record’s field. But from the example given, I can’t see how/why that should happen. There seems to be nothing overt in the script which indicates that action. Apparently there is some invisible TapForms code which “magically does the right thing” in some unspecified set of circumstances. I believe that in one of your Forum posts, you said something to the effect of “when Tap see this in your script, it does <something>”, which is not in the basic description of the operation of “this”. Where is all of this sort of thing documented?
FYI: I’m a retired programmer who completely understands that it’s more fun to write code than to write documentation. But I think that for an app as powerful and useful as Tap Forms, a little more work in the latter might be helpful.
-
AuthorSearch Results