Hi Da,
You can use the Scripting functionality to post any Tap Forms content to a web service now.
See the scripting topic in the online user manual here:
https://www.tapforms.com/help-mac/5.3/en/topic/scripts
There’s functions for posting and getting content from any web service. There’s even an example script on that page that shows you how to call out to a web service to fetch movie data given a barcode value.
Thanks,
Brendan
Daniel,
Thank you. You are right I was looking at SQL rather than JavaScript.
Even replacing OR with || still generated an error. It was only when I realised that there was an extra “(” which caused still caused an error:
if (DocumentType.includes("passport") || *(*documents_details.includes("passport")) {
before the document_details variable…
The SQL documentation doesn’t really help much as this is Javascript that you should refer to: https://www.w3schools.com/js
The logical OR operation in JS is ||. includes is a method used on arrays, you might look at match instead (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match).
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
I have two variables in a script (DocumentType or Documents_Details). One or the other contains text.
I wish to see if either of them include a specific word (Passport).
I set up an IF condition to test:
`if (DocumentType.includes(“passport”) OR (documents_details.includes(“passport”)) {
console.log(“there is a passport here”);
} else {
console.log(“there is NO passport here”);`
But get an error message:
“I-CertDoc: SyntaxError: Unexpected identifier ‘OR’. Expected ‘)’ to end an ‘if’ condition., line:153”
I tried to follow what is on this page: https://www.w3schools.com/sql/sql_and_or.asp, but it is not producing the desired result. Any help would be gratefully received.
Daniel,
Thank you for the information.
It has to be in JavaScript as is needed for use within a longer script.
The easiest I think would be to use a calculation field instead of a script field: DATEADD([date_of_notarial_act];0;0;0;5;0;0;0).
Or in Javascript
// Create date object
let write_up_notarial_register_date = new Date(date_of_notarial_act);
// Add five days to current date
write_up_notarial_register_date.setDate(write_up_notarial_register_date.getDate() + 5);
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
In a document I have a date field which is referenced such has
var date_of_notarial_act_id = 'fld-76fd68bf708e4bde87998a0cba32ffcd';
var date_of_notarial_act = record.getFieldValue('fld-76fd68bf708e4bde87998a0cba32ffcd');
but I would like to add 5 days to it and then that new date written to another form. Doing something such as:
var write_up_notarial_register_date = date_of_notarial_act + 5;
Does not work. Is what I would like to do possible with JavaScript in Tap Forms?
Any help would be gratefully appreciated.
Hi, I have a To-Do List form with hundreds of records. I am trying to duplicate the form with all of its records so that I can separate my Home tasks and Work tasks into two separate forms.
I tried to Export a Tap Forms Archive, and then import it back in, but it just overwrites the original form. I want to load it back in as a second, additional form. Then I will delete the Work tasks from my Home form, and I will delete the Home tasks from my Work form.
What’s the easiest way to do this?
I am using Tapforms for iOS (and am pretty comfortable using javascript if need be).
Thanks,
Pinny
Well, I am giving up on scripts. I keep going round and round with this. I get the script to work in the console window while editing and then I go to the form and the field doesn’t update. I refresh both tables and go back to the script edit window and now the console values don’t work. So frustrating. I think there is an update issue in the software.
That’s a good tip! Thanks Brendan.
My script still isn’t working the way I wanted it to because in the Donations table I still have to manually select the Parent data in the “People” inverse relationship field. If I don’t select anything my script doesn’t work. I wanted to be able to put the Envelope ID in the Donations record and have it automatically look up all the relevant data in the People table. I don’t know if I am making any sense or not.
People Donations
====== =========
Envelope Envelope (manually entered)
First Name First Name (auto fill from the script)
Last Name Last Name (auto fill from the script)
Anyway, I think I am going to just have one form and put the Donations on each person’s data in the People table.
Thanks,
Chris
You can use console.log() to output variables and text to the console:
console.log(var);
console.log("text");
Depending on the object, you might want to use console.log(JSON.stringify(var)).
To create an alert, use Utils.alertWithMessage('Script Run Complete!', 'Cool!!!!!');
Hope this helps!
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
I am trying to debug a script. How can I print or show an alert?
hi Chris,
The Child Records Loop snippet is designed to fetch the child records, not the parent record. So in your case, the People form is the parent and the Donations form is the child. So if you wanted to put a field on the People form that say, concatenated all of the donations for that People record together, that’s when you would use the Child Records Loop.
Yes, Documents are like Databases. Logically and technically as each .tapforms document is actually a folder that contains within it its own SQLite database.
And yes, Forms are like tables precisely. Records are of course like SQL records and fields are like Table Columns in SQL.
If you want to automatically connect your forms together based upon some key field, then you would need to use the Join Link Type on your Link to Form field and set the common fields up. Then Tap Forms will auto-join for you.
But that does in fact change the JavaScript code you would need to get the name values. Because with a Join Link Type, that is in fact the same as an automatic Many to Many relationship. That is, for each Donation record, there technically could be many People records and for each People record there could be many Donation records.
So now when you get the value of the People field from the record, you’ll get an array instead of just the one object like in my code example. In this case, the Child Records Loop would work as expected.
Hope that makes sense.
Thanks,
Brendan
Hello again Brendan,
I guess what I was originally trying to do, was write a script that:
1. Automatically connected each donation to its parent record based on Envelope number.
2. Automatically fill in the name field based on the Envelope number found in the parent record.
Number two is what you just helped me with, however I had to manually select the parent record in the Inverse Relationship field, by looking up and connecting the correct Envelope number for the person. I know you have removed the SQL language, however now I have to understand the inner modeling of the application in order to write Javascript to pull the data.
Still learning,
Chris
By the way, to write that code, all I had to do was double-click on the People field on the left side of the Script Edit window. Then double click on the First Name field. Then all I typed was the return first_name and I wrapped it into a function structure.