Tap Forms app icon half
Tap Forms Forum text image
Blue gradient background

Exchange tips and ideas with the Tap Forms community

Search Results for 'script'

Viewing 15 results - 2,506 through 2,520 (of 2,950 total)
  • Author
    Search Results
  • #34945
    Sam Moffatt
    Participant

    I 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 addNewRecordToField approach 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

    #34933
    Kana Ne
    Participant

    Is 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,
    Kana

    #34721
    Brendan
    Keymaster

    You 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.

    #34718
    Bert Rietveld
    Participant

    Is 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.

    #34708
    Stephen Martin
    Participant

    Thanks, 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.

    #34685
    Gilles Cruypenynck
    Participant

    Hi,

    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

    #34655
    Kimberley Hoffman
    Participant

    I 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,
    Kimberley

    Attachments:
    You must be logged in to view attached files.
    #34571
    Brendan
    Keymaster

    You 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.

    #34448
    Barry Shevlin
    Participant

    Thank 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?

    #34426

    In reply to: V5.3 Manual

    Brendan
    Keymaster

    Modifying 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.

    #34423

    In reply to: V5.3 Manual

    Dave Emme
    Participant

    OK, 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!

    #34420

    In reply to: V5.3 Manual

    Brendan
    Keymaster

    Hi 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 fx button is how you access the Snippets, which are the little bits of code that Tap Forms writes for you to do different things. The field button just to the right of the fx button 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 the record.getFieldValue() function for you or just generate the var 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

    #34419

    In reply to: V5.3 Manual

    Dave Emme
    Participant

    Brendon 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.

    #34402
    Heath Goodman
    Participant

    Hi Brendan- Just wanted to ask- I know there has been some discussion about user roles/security/passwords for layouts, etc. I hope you are considering these options in near future updates.
    I really love your Tapform program, its easy to design and very user friendly even better than Filemaker Pro I think. I have started designing a small business database CRM/Catalog/Invoice system for my business and it looks like it would work out so beautifully… However, I will need to give access to other sales people on my team to some of the database and wanted to also lock out other parts and especially the “design mode” so that I don’t have layout nightmares with sales people accidentally modifying/deleting set layouts or deleting an entire form or database structures. I need to find a solution if I am to actually use TapForms as my business engine. Do you know if there is any solutions to these matters to use Javascripting or other implementations to making this work with TapForms? I was wondering if these things might be more easily implemented if perhaps there was a way to interface the TapForm core database to perhaps a frontend browser database application such as Open Source NuBuilder Forte https://www.nubuilder.com (which has a user role type setup) or something like it that would work as a internet accessible frontend to TapForms but make it difficult for your staff to screw up hours upon hours of database entry/forms/layouts with one accidental click of the button. Please tell me there is a solution cause up to this point TAPFORM ROCKS! I need a solution ASAP and thought TapForms was it and hope it still can be… Thanks Bro!

    #34384
    Brendan
    Keymaster

    Hello Kana,

    Thanks for discovering Tap Forms!

    The Invoice Tracking template that I have here would be a good start to get you going with building this:

    Invoice Tracking Template

    It has a Products form that contains a list of products to choose from, plus an Orders form where you create an Order. Within the Order is a Table field called Order Items. The Order Items table has a check button you click on to display a list of Products from the Products form. When you select a Product, its values are copied into the record within the Table field. It uses the names of the sub-fields in the Table field to match up with the names of the fields in the Product form to know what to copy in. From there you can change quantities and prices and whatever you want.

    The one thing it doesn’t do is update the quantity in stock of the products after you select the product to add to the Order Items table.

    But I think it would be possible to write a Script that could update the quantities on hand in the Products table given the quantities that were entered into the Order Items table for the Order. It would take a bit of work to build a script to do that though. But the basics of what you’re asking for are definitely there in the Invoice Tracking template that you can download.

    Thanks!

    Brendan

Viewing 15 results - 2,506 through 2,520 (of 2,950 total)