Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
July 21, 2020 at 8:27 AM #41419
In reply to: Script for Printing
T.L. Ford
ParticipantThe for loop changes to add the time:
// loop through the songs records for (var index = 0, count = songs.length; index < count; index++){ // get the Song Title from the current record var song_title = songs[index].getFieldValue(song_title_id); // get the song time from the current record var song_time = songs[index].getFieldValue(time_id); // if a song title exists if (song_title) { // if we have a time, go ahead and add it to the song_title string if (song_time) { // shorthand for song_title = song_title + ", " + song_time song_title += ", " + song_time; } // add the song title to the array song_titles.push(song_title); } }The javascript term is “string concatenation” – fancy for “adding two strings together” (strings are javascript’s way of saying text). While I’m at it… an “array” is javascript for “a list of something”.
July 21, 2020 at 7:22 AM #41417In reply to: Script for Printing
Victor Warner
ParticipantT,
Thank you very much for providing the example – it helped me understand where I was going wrong in implementing Brendan’s example (failure to pick up the difference between Song Title (the form) and Song Titles (the field name)) – without reference to the database I did not appreciate the difference.
I cannot say I understand some of the code but I should be able to implement it at least.
One query on an addition. If I wished to display a second field in the resulting script, how would I do this?
For example, if I added a time field (as a text field) and then instead of display, e.g.
Barry Went Out
Bee Bounce
Party Onbut instead
Barry Went Out, 1:30
Bee Bounce, 2:30
Party On, 1:30I understand how to get the id of the time field into the script (and how to write the code to format shown immediately above, just not how to get into this part of the script:
// create an array to store the songs in var song_titles = []; // loop through the songs records for (var index = 0, count = songs.length; index < count; index++){ // get the Song Title from the current record var song_title = songs[index].getFieldValue(song_title_id); // if a song title exists if (song_title) { // add the song title to the array song_titles.push(song_title);Help with this part would be greatly appreciated. I attached the datebase with the added field.
Attachments:
You must be logged in to view attached files.July 20, 2020 at 7:27 PM #41408In reply to: Tables – duplicate between forms
Sam Moffatt
ParticipantIf you have script, why not just have it add new entries to a table in the other form?
July 20, 2020 at 12:19 PM #41406In reply to: Script for Printing
Brendan
KeymasterT.L. I don’t mind one bit! I love it when customers help each other and it’s exciting for me to see what new things people want to use Tap Forms for. The scripting engine has been especially great because it opens up a whole world of possibilities for different ways to use Tap Forms.
July 20, 2020 at 12:02 PM #41401In reply to: Script for Printing
T.L. Ford
ParticipantVictor,
This looks like this. I modified Brendan’s code to add comments explaining each line of the Javascript. Working example attached.
Brendan – hope you don’t mind me adding things. I’m happily enjoying exploring your Tap Forms application and am learning new and better ways to do things.
– T
Edit: Technically it’s not the id of the song form, but the “link to form” field on the Genre form.
Attachments:
You must be logged in to view attached files.July 20, 2020 at 9:44 AM #41397In reply to: Script for Printing
Victor Warner
ParticipantSorry to highjack this thread, but it would be very helpful for beginners (such as myself) to have a worked example.
Would it be possible to provide a simple database showing an example of how this works, as I tried to follow the original’s posters requirement and adding a script field wit the code but I just get errors.
July 19, 2020 at 1:57 PM #41384In reply to: Tables – duplicate between forms
David Oxtoby
ParticipantCheers for that Sam, what i ended up trying and seemed to work for what i needed, was create a script field that reads all the entries in my table and create a formatted text return value (not shown on the booking form), and then in the linked invoice form, i have another script field that pulls from the linked form that new formatted return value and shows that instead.
A bit of a faff inserting tabs and padding to to get the formatting looking ok, but works for what i needed.
see screen shots for idea of what it looks like… The Venue Booking shows the rooms being hired, that has been output into a hidden field, which the Invoice breakdown then shows in another scripted field.
Attachments:
You must be logged in to view attached files.July 19, 2020 at 1:33 PM #41383In reply to: Tables – duplicate between forms
Sam Moffatt
ParticipantIt sounds like you’ve got two forms already and you want the same table on the two different forms. I’d suggest adding a third form that has the same structure as your table field and then use a “Link to Form” with the “JOIN” type. JOIN uses a field value that is common between the two forms to automatically build the links. In your case I think a customer ID would be a reasonable link value because you can put that on all three forms and link it together.
The Link to Form behaves similar to the table so you should be able to get the same effect in both places relying upon the same data.
Now I have a feeling that you might need this in thee future but a trick you can do with JOIN fields is to use a calculation field to JOIN on. You can use a calculation field to combine the values of two different fields together (via
CONCAT) and use that value. In your example I can imagine a customer at some point stopping a service at which point they shouldn’t get invoiced for it in the future but you might want to include it in their printed invoice. You could add a checkbox or other flag that you check and use as a part of the composite key. The downside of this approach is that older invoices if reprinted will look different, so let’s think about that.A JOIN field is great because it automatically updates values for you. A JOIN field is unfortunate because it automatically updates values for you. Thinking about “what services does the customer currently have active”, what you could do is when you generate an invoice you use a script to manipulation a normal “Link to Form” M:M field instead of a JOIN field. You would need to write a script to handle creating a link from the third form we created above to do it.
Give the JOIN field a try and see how it works out for you, if you feel we need to go down a little deeper on the scripted approach then I can give you a hand with that too.
July 19, 2020 at 7:42 AM #41381Topic: Tables – duplicate between forms
in forum Using Tap Forms 5David Oxtoby
ParticipantI did a search, but couldn’t find anything that offered a solution….
So, i have a table on one form that is a break down of the services a customer is receiving, (item, price, etc), and then on my invoice form which is a summary, i want to also show the same breakdown table, but without adding all the items in again from scratch. So…. is there a way when linking two forms, to show the table field from one on the other, it looks like there isn’t, therefore is a work-around….
have a script in the from that holds the table, to somehow extract the table content into a hidden text field that somehow formats the text, and then on the linked form just show that formated text field instead of a table?
or am i missing something really basic here…… many thanks
July 19, 2020 at 5:54 AM #41377In reply to: Reminder Calendar
T.L. Ford
ParticipantThat is an incredible amount of calculations you’ve managed there. I’m still trying to figure out how you made it all work. Reminds me of some spreadsheets I’ve created.
I’m attaching an equivalent form done with scripts merely for comparison. It’s a different solution, not necessarily a better solution.
Attachments:
You must be logged in to view attached files.July 18, 2020 at 11:27 AM #41367In reply to: Hide fields with script
Daniel Leu
ParticipantTap Forms needs a javascript call to refresh the form display (similar to the View | Refresh Records List menu item).
+1
I’ve been asking for such a feature for a long time… Nice to see someone else wanting it as well :)
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksJuly 18, 2020 at 10:34 AM #41361In reply to: Hide fields with script
T.L. Ford
ParticipantTap Forms needs a javascript call to refresh the form display (similar to the View | Refresh Records List menu item). This would also solve a script on a many-side not correctly refreshing the view on the one-side.
Tried several ways (attached), but none are an acceptable solution.
Attachments:
You must be logged in to view attached files.July 18, 2020 at 5:46 AM #41359In reply to: Medicinal Herb Database template request
T.L. Ford
ParticipantNot too sure what happened to my reply, so I’ll repost. I just got Tap Forms and am playing around with it and this request, although long deprecated, was an interesting challenge. Here’s my solution.
http://cattail.nu/tap_forms/Apothecary.tapforms.zip (2mb – it’s an archive with demo data and help table).
The data schema is attached here and shows the one-to-many relationships in use.
The calculation update is in one monolithic script and I’m now playing with record-level script fields.
Attachments:
You must be logged in to view attached files.July 17, 2020 at 8:28 PM #41356In reply to: Script for Printing
Brendan
KeymasterHi Roy,
Maybe you don’t need a script to do this. Have you tried just printing out the Default Layout and see what kind of output you get?
However, you can create a new field and select Script as the Field Type. Then select your Song Title field from the list of fields on the Script Editor. Then double-click on the Child Records Loop Snippet and Tap Forms will write the code for you to loop through all of the Songs for the selected record. Then all you need to do is concatenate them together into a single string and return that.
Something like:
function SongTitles() { var songs_id = 'fld-1ad42e9404674124aa6871c367249f1d'; var song_title_id = 'fld-177726d9d3b44645941e6d6488bcfbd1'; var songs = record.getFieldValue(songs_id); var song_titles = []; for (var index = 0, count = songs.length; index < count; index++){ var song_title = songs[index].getFieldValue(song_title_id); if (song_title) { song_titles.push(song_title); } } return song_titles.join("\n"); } SongTitles();July 17, 2020 at 7:52 PM #41352In reply to: A Few Questions
Brendan
KeymasterActually you can now…
tapformz://form/view/db-xxx/frm-xxxand you can execute scripts:
tapformz://script/db-xxx/frx-xxx/scriptName -
AuthorSearch Results