Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
Sam Moffatt
ParticipantI’m not as sure about how to do this on iPad as I do most of this on the Mac and sync it over using CouchDB to my iOS devices however you should be able to do all of this on iOS as well.
1. I duplicate the entire document and then export the forms to a new document from time to time. If you use the duplicate option in Tap Forms on a document, it’ll give it a new document ID and isolate it for you. This is useful for testing, making sure sync doesn’t accidentally go somewhere you don’t intend and gives you the confidence that you can delete everything and start from scratch. The other thing I do is export the form template and load it up into temporary documents to toy with things.
2. You can recalculate either an individual record or all records in a form. To recalculate an individual record, on iOS you can drag down a record to recalculate it’s formulas and on the Mac use the refresh button at the bottom of the record layout or use the menu to go to “Records” > “Refresh Selected Record”. To recalculate an entire form, on iOS you can drag down the record list to recalculate and on the Mac use the refresh button at the bottom of the list for the view you are using or use the menu to go to “View” > “Refresh Records List”. Tap Forms will automatically recalculate a calculation when you change a referenced field unless you have the calculation field set to “Calculate only one time” (useful mostly for functions that use
UUID()or some other fixed, one time operation). Similarly when you click refresh/drag down, it will ignore any “Calculate only one time” fields as well.That said if you’re happy to wait a moment, refreshing an entire form isn’t the end of the world. I do it on my calculation and script heavy forms all of the time and it’s only a mild inconvenience. Many of my script fields also invoke web API’s hosted within my network, so I can easily see when I make that mistake. I do wish if Tap Forms notices it’s taking longer than a few seconds to recalculate that it gave some sort UI popup indicate where it’s at with stuff.
September 1, 2019 at 10:36 PM #36659In reply to: How to repair calculation(s)
Michael Harding
ParticipantHi Sam. Again: many thanks for your help. It puzzles me that this formula once worked for me and continues to for me in one area of my form (the ‘discounting area’ versus the ‘unit cost’ calculation).
Nevertheless, I’ve spent hours trying to come to grips with it and did succeed in getting one cell to link to the total cost calculation result. Replicating the formula for other cells didn’t and doesn’t work.
I’ve looked everywhere and into everything to divine why this is so. Nothing seems to present itself and my analysis suggests that the problem isn’t so much the equation/scripting but an error somewhere else.
The cells are all correctly set up as number cells. They link in the correct order, as Brendan suggested doing a few days ago. But there must be something incorrect in the way Tap Forms is seeing the cells.
I have been through the various cells checking and checking and just don’t see where the problem lies.
September 1, 2019 at 2:25 PM #36655In reply to: Pick list for date fields
Brendan
KeymasterHi Helmut,
Pick Lists don’t work for Date fields because you already get a popover view to select a date from the calendar.
Thanks for the feature suggestion for a fixed date value for a Date field.
One option would be to write a Form Script which you use to create new records that also sets a fixed date value for your Date field.
Thanks!
Brendan
August 31, 2019 at 10:47 AM #36643In reply to: Movie script
john cesta
ParticipantI guess I’m not sure how to use it.
Earlier I was opening a record with data in it. For that I received the no record error.
Now I opened a new record. When I run script it runs with no found data, no error either though.
So my guess is that it is searching for something but not finding anything so no results.
What I don’t know is how to tell the script what to look for. Do I need to have the barcode_field in the record filled in with a valid barcode for the movie I want to find? If so where do I find that barcode for the movie?
Can it use the title of the movie?
August 30, 2019 at 7:13 PM #36640In reply to: Movie script
Brendan
KeymasterMake sure you’ve selected a record first, then tap the action menu, then tap Run a Script from the record details view. The
recordobject should be available at that time.August 30, 2019 at 3:16 PM #36635In reply to: Movie script
Sam Moffatt
ParticipantThe error is indicating
recordisn’t set in the context it’s trying to be used. On the Mac I’ve seen this when running a form script when there isn’t a record available. I think on iOS I’ve seen if where if you run a form script from the record list, this will happen because there is no record. If you’re running a form script from an open record and seeing this on iOS then that would be a bug I think. I think on iOS I have also run into this when in the script editor in certain places as well.Do you mind sharing what you did and where you were at before triggering the error?
August 30, 2019 at 8:51 AM #36630Topic: Movie script
in forum Using Tap Forms 5john cesta
ParticipantWill the movie script work on the iPad mini tap forms?
I wasn’t sure if it’s only for the Mac.
If it works on the mini I’ll putt with it.
August 30, 2019 at 4:26 AM #36625In reply to: How to repair calculation(s)
Michael Harding
ParticipantHmmm. Actually, I think I must have scripted those equations initially in Bento, which explains perhaps why I didn’t recall scripting the IFEMPTY commands…
August 30, 2019 at 12:19 AM #36613In reply to: Programmatically set record color
Brendan
KeymasterHi John,
Not at the moment. But in the next update I’ve added a method called
record.setRecordColor()which would let you do that by giving it a web colour in hex format. E.g.record.setRecordColor('#FF00CC');It requires you use the Scripting engine though.Here’s an example I just tested:
function Record_Colour_Script() { var number = record.getFieldValue('fld-046db84197fd44a6adf50b3a9ab426d5'); var colourHex = '#005090'; if (number > 20) { colourHex = '#c59'; } else if (number == undefined) { colourHex = 'CLEAR'; } record.setRecordColor(colourHex); form.saveAllChanges(); } Record_Colour_Script();It won’t work yet in the production Tap Forms version. But it will in the next update.
August 29, 2019 at 11:07 PM #36610In reply to: Automobile VIN Lookup Script
Sam Moffatt
ParticipantThe
Utils.getJsonFromUrl()returns a JavaScript object directly. You don’t need to parse the JSON file, Tap Forms does that for you and creates a nested set of Javascript dictionaries and arrays.The Google Books API response is a little convoluted, what you want is a few levels deep. You might want to look into grabbing a JSON formatter for your favourite web browser to help see the layering in the responses with a tree format.
Here’s something simple to get you further along:
function Json_Request() { let data = Utils.getJsonFromUrl('https://www.googleapis.com/books/v1/volumes?q=isbn:9780061143397'); console.log(data['kind']); for (let i = 0; i < data['items'].length; i++) { let item = data['items']; let volume = item['volumeInfo']; console.log('Title: ' + volume['title']); console.log('Print Type: ' + volume['printType']); console.log('Authors: ' + volume['authors'].join(', ')); } } Json_Request();This is a form script I started, it’s intended to run from the editor and use the console to log out the data. You’d need to update it and change it to do what you want.
EDIT: Ok, I think I understand where you might have gotten stuck.
Javascript lets you use array syntax (e.g. the square brackets) to access dictionaries, arrays and also strings. To access a dictionary, you use a key lookup (e.g.
data['items']); to access an array, you generally use numeric lookups (e.g.results[0]) and you can also access a string and it will give you the character at that offset.Quick example of the string output using a form script as a vehicle:
var mystring = 'Test'; for (var i = 0; i < mystring.length; i++) { console.log(mystring); }Will output the following in the console:
T e s tBecause it’s treating the string as an array of characters instead of giving you an error. I get caught by this from time to time and it sometimes takes me a moment to realise what I’ve done.
If you find yourself hitting this then you’re probably iterating over a string instead of the array you were intending. Hopefully this helps.
August 29, 2019 at 8:07 PM #36602In reply to: Automobile VIN Lookup Script
Mark
ParticipantThanks for your response – it helped me realize that I don’t know how to parse through a JSON array and/or nested arrays.
In playing with my script, I seem to be able to read one character at a time.
I’ve tried looking at some tutorials, etc. but they seem to use functions not available within Tap Forms scripting. Could you provide a simple example or point me to one so I can learn?
This is a really powerful feature that I’d like to be able to use.
Thanks again,
MarkAugust 29, 2019 at 6:25 PM #36599In reply to: Automobile VIN Lookup Script
Brendan
Keymaster@Mark, can you post your script?
That’s a JSON result, so it should work to parse as long as you parse it right. Note that
itemsis an array, so you’d have to get that and then loop through those items and pick out any data you need.Basically it’s just recognizing what returned elements represent an array
[ ... ]and what elements represent a dictionary{ ... }and get the values appropriately.August 29, 2019 at 4:35 PM #36594In reply to: Automobile VIN Lookup Script
Mark
ParticipantHi – I’m trying to copy your approach on this VIN script to pull book details from Google Books API, but the data I can’t get the resulting data to parse the way this script works with the NHTSA data.
here’s a sample URL
https://www.googleapis.com/books/v1/volumes?q=isbn:9780061143397Where you refer to ‘Results’ in the NHTSA data, I’ve tried ‘item’ ‘kind’ etc. but it does not seem to recognize the data structure.
I have a feeling I’m missing some detail about how to access the data’s structure.
Thanks for any insight,
Regards,
MarkAugust 28, 2019 at 6:29 AM #36576In reply to: Re class a field typer after script. (Web Location)
Sam Moffatt
ParticipantYou’ll need to create a new web site field to put the data into. Then your script just needs to know what that field ID is and then set it:
form.runScriptNamed('vlookup'); var trello_cards_id = 'fld-a6346935a6af40d1833fad4f49958bca'; var tsm_rfs_id = 'fld-b0c9111f87064a23bde75c965374e97c'; var short_url_id = 'fld-7888517ad8204f5aa7a4bf926c92be15'; var website_id = 'fld-yourfieldhere'; var rfs = record.getFieldValue('fld-e13aa1493c6f4b919f30b27cd8bc8ae9'); var website = vlookup(rfs, trello_cards_id, tsm_rfs_id, short_url_id); record.setFieldValue(website_id, website); website;Something like that should work, hopefully it makes sense.
website_idis the new field you add to store the URL and make clickable, I putwebsiteinto a variable so that I can use it to set and then use it as the return value for the script (kinda redundant but not harmful). You could probably hide the script field once it’s all working.EDIT: Updated to remove smart quotes. If you have smart quotes, things won’t work the way you expect and you’ll get errors from JavaScript. If you’re working on iOS, make sure you use the quote button above the keyboard to ensure you don’t put in smart quotes accidentally. On the Mac, it usually doesn’t input smart quotes so you’re safe there.
August 28, 2019 at 5:21 AM #36575In reply to: Re class a field typer after script. (Web Location)
matt coxon
ParticipantHi Sam, thanks very much for the response, I understand what you mean but can’t seem to get the syntax correct
Do I add the command to the main script field after the vlookup or in a new script field I played around with various but can’t seem to get it to work, but when I do I’ll need to apply it to date fields in the same scenario as the web field so will be very useful
Thanks
-
AuthorSearch Results