Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
July 16, 2020 at 11:48 AM #41312
In reply to: A Few Questions
Christin White
ParticipantThanks Sam and Brendan!
Sam,
1. Brendan’s solution seems to have resolved the issue for now, if I have more trouble with things in the future I may look into those other services.
2. Hmm, I hadn’t considered this approach but having one form for all media seems like a more elegant solution than a bunch of forms, even if it means I have a ton irrelevant metadata for each record, I’m liking this better! I’m not much of a fan of custom layouts though, I hadn’t realized those were an option before you mentioned them but playing with it now it seems very paper/page-centric in design, not really UI-centric and responsive to different device screen sizes. I wish I could just take the default layout but just hide fields for each layout. I may play with this more but it seems to lack the elegance of the default layout. I’m definitely spoiled coming from AirTable in terms of design elegance, I just wanted something native and not limited by subscription pricing tiers.
3. Good point, certainly, but that was just an example, combining things like media types or companies and individuals may not always make sense. I can work around this but it’s a shame there isn’t more control.
4. I get that but it’s a pity it doesn’t collapse the table if there’s only a single relationship or a many to one option.
5. I’ll take a look at your scripting, I was having trouble describing the system in a clear way. Basically, I want a tagging system sort of like thisParent Tag 1 (record 1, record 2, record 3 - collected/reverse inherited from children) Child Tag 1 (record 1, record 2) Child Tag 2 (record 3)Bear parses tags by just using slashes in the tag names like
Development/Languages/Javascriptbut that’s only one approach. Keep It for instance doesn’t do hierarchical tags but if you filter by a tag the tag panel will then show you other tags that associated with items that has that tag so hierarchy can be implied through boolean unions.A programmatic solution where any record that is assigned
Child Tag 1would automatically tag it withParent Tag 1would certainly work if Tap Forms’ scripting support is robust enough parses regex expressions, assign and remove tags, it sounds like it is.I need to explore a little more, look at that keyword mapping and figure out what you’re suggesting a bit better when I have more context.
—
While not as flexible in some ways as I would like it seems like Tap Forms will work for me and is worth the investment, it is an awesome system and I realize I’m probably an outlier for some of the ways I want to use it
July 16, 2020 at 2:03 AM #41306In reply to: Tap Forms for Magazines
pierrot_rennes
ParticipantHi Sam,
I put only one keyword per article to keep it simple
If I really need a second keyword for the same item, I create a second record
Apparently, your script works according to my need.
I will test by adding some articles.
If it’s ok, I will start from your model to modify your form and adapt it to my needs
A big thank you for your responsiveness, I will tell you when it’s goodJuly 16, 2020 at 12:12 AM #41302In reply to: A Few Questions
Sam Moffatt
ParticipantHi Christin,
Responding as a regular user, some of these will require Brendan’s input.
1. I suggest looking at CouchDB or Cloudant as the sync system, I’ve found CouchDB to be reliable and if you’ve only got a small amount of data the IBM Cloudant free tier I think gives you 1GB of space to use (CouchDB is an open source server and Cloudant is IBM’s hosted version of it).
2. I’d probably leave all of those fields in a single form with a “type” field and then use custom layouts to control which quote you saw. It won’t work so well on the table view but a workaround would be to use either a calculation field or a script field to compose the text relevant to the record type, perhaps like a bibliography line generator. You click add, in the ‘quotations’ form select the right layout for th type, put in the data and then you can go back to the parent form.
3. Companies are people too, at least in the US anyway. I’d actually take inspiration from Apple’s approach where if a contact card is a company is a tick box for the contact card and everything else more or less remains the same. You can still filter and search on if something is a company or not and if you bump it up your field list after name, you can have it render in the list view as well (I’d also tick “show field name” on the checkbox as well). I don’t think you can hide the UI if there is nothing there.
4. Many to Many implies both sides could have multiple entries though, that’s why it’s displaying the table because there is the possibility that multiple records will be available or another one could be added even if there is currently only a single record.
5. I’m not sure I fully understand so my apologies if I’m off base but what might work for you is something not dissimilar to what I just threw together for Pierrot for his keywords mapping for magazines. Some amount of scripting could help automate building the linking structure you’re interested in achieving though I must admit I’m not sure I fully understand it. There are a couple of ways of structuring the forms to use calculation or script fields to create surrogate field values (e.g. take the name of the current level such as
Habitsand then prepend a field with the name of it’s parents) which if set to be the first field shows up in the flat list but can maintain the parent association via a 1:M link. Then I’d probably use a normal Link to Form M:M field to map the children of each of the category records to it’s categories that is maintained by a script. You could brute force like the above script or a field script might also work to detect links being manipulated and to automatically propagate adding/removing the links internally.Hopefully that makes sense, I’m sure others on the forums might have different takes and Brendan often chimes in with features that are built in that might handle some of it. I think with some scripting support you can get a little bit further.
July 15, 2020 at 11:37 PM #41299In reply to: Tap Forms for Magazines
Sam Moffatt
ParticipantIf you only had one keyword, then I think a JOIN link to field type would work for you because you could have a single “keyword” record and then it’d automatically JOIN on other records. If you made “articles” it’s own form and used “Link to Form” fields to join it all together then that would work. You’ve gone with a table approach which can’t be used to handle the JOIN.
If you wanted to keep the table, what could work is to leverage a script to maintain the links. I did a really quick one here;
function Build_Keyword_Map() { // This is the other form that has our keywords in it. let keywordForm = document.getFormNamed('Keywords'); // This is the field ID in the "keywords" form for the link to field to Magazines. let magazines_id = 'fld-b4724a28d4094b3faa9910f18374588f'; // This is the field ID in the "keywords" form for the keyword field. let keywords_keyword_id = 'fld-ebaf7ffa3d484834bdcc34d3ffb9c5f2'; // This is the field ID in the "magazine" form of the table. let articles_id = 'fld-dca513dfa3894e8aaa3792a9eb09b106'; // This is the field ID in the "magazine" form for the keyword field in the articles table. let keyword_id = 'fld-055da0f29f764ea399e6f317427ff8ed'; // This is to store a map of keyword to keyword record. let kwRecords = {}; // Build the map of keyword to keyword record (cache if you will). for (let keywordRecord of keywordForm.getRecords()) { kwRecords[keywordRecord.getFieldValue(keywords_keyword_id)] = keywordRecord; } // Iterate over every record in this form... for (let sourceRecord of form.getRecords()) { // And iterate over each row in the articles table... for (let article of sourceRecord.getFieldValue(articles_id)) { // Get the value of the keyword field... let keyword = article.getFieldValue(keyword_id); // Skip it if it is empty... if (!keyword) { continue; } // Check if a keyword record exists for it... if (!kwRecords[keyword]) { // Create keyword record if it doesn't exist... console.log('Creating keyword record'); kwRecords[keyword] = keywordForm.addNewRecord(); kwRecords[keyword].setFieldValue(keywords_keyword_id, keyword); } // Link the keyword record to this record. kwRecords[keyword].addRecordToField(sourceRecord, magazines_id); // Save the changes to make sure the link persists properly... form.saveAllChanges(); // Log the keyword we processed, we're done! console.log(keyword); } } } Build_Keyword_Map();There are comments throughout which should explain what it does and I’ve attached a sample archive with the script in it inside the “Magazine” form. You can play with it to get it to add links. What it doesn’t do right now is handle if you delete or remove a keyword. You’d also have to do a split or similar to do a comma separated list of keywords as well but this is a quick example of how you can use scripting to build that link.
If you change from a table to a child form then you could link a single keyword easily. If you wanted to do multiple keywords (e.g.
Big Sur, Photos) then you’d be back needing a script again.Hopefully this helps :)
Attachments:
You must be logged in to view attached files.July 14, 2020 at 6:51 AM #41279Topic: Script for Printing
in forum Script TalkRoy Helsing
ParticipantI am new to TAP, and made a simple relational database for a lost of music I can play, attached to the genres that relate to that music. I want to be able to print a report for my customers that lists each genre and under it, all song titles that are related tot hat genre. It appears the thinly way to do that iw with a script – which I read about at length yesterday only to decide Java Script is not in my wheel house. Does anyone have a simple script they use to list related items under a field that could share? I think i am able to figure out how to replace the fields in someone script with my one. I am looking for a report that reads like this:
GENRE 1
Song 1
Song 15
Song 432
Genre 2
Song 15
Sonf 321
Genre 3
Song 1
Song 12July 11, 2020 at 4:58 PM #41263In reply to: how to link fields when typing
Sam Moffatt
ParticipantYou can use any of the scripts I wrote with pick lists. You just need to define the two pick lists in the Tap Forms preferences for your document and assign each of the text fields to the correct pick list. Make sure you use a single value select list type (e.g. single value popover, combobox, popup button or radio) because the multivalue varieties would mess up the mapping.
July 11, 2020 at 12:54 AM #41257In reply to: how to link fields when typing
Brendan
KeymasterOops. Actually you’re right. Because the script doesn’t get executed until you select from the first pick list. Darn.
July 10, 2020 at 12:28 PM #41249In reply to: how to link fields when typing
Brendan
KeymasterI know it’s not the same as what you’re doing, but I did once write a script that switched pick lists depending on the value selected from another Pick List. This script switches between a Canadian Provinces and US Sates Pick List depending on the value of the country selected.
function Province_Pick_List_Switcher() { var country_id = 'fld-de7985c881804154b037c68dc4c24414'; var country = record.getFieldValue(country_id); var canadian_provinces_pick_list = document.getPickListNamed('Canadian Provinces'); var us_states_pick_list = document.getPickListNamed('US States'); var province_id = 'fld-b1458c16690744129ff145f7b9607c99'; var province = form.getFieldWithId(province_id); if (country == 'Canada') { province.pickList = canadian_provinces_pick_list; } else if (country == 'United States') { province.pickList = us_states_pick_list; } else { province.pickList = null; } } Province_Pick_List_Switcher();It worked well, but only with the Single and Multi-Valued Pick Lists. Because those fetch their Pick List values when you display the popover as opposed to the Checkbox, Radio Button, Combo Box, etc., which pre-load all the values to display.
July 10, 2020 at 12:29 AM #41244In reply to: how to link fields when typing
Sam Moffatt
ParticipantI re-read this and thought I might be overthinking things, if you want a simple 1:1 mapping something like this might work for you. Create a script field and then use a switch statement to pick the right value.
Here’s an example of autocompleting a country based on a “state” field. I use a switch because I think it’s pretty readable though you could construct an array as well:
function Autocomplete_Country() { var issuing_state = record.getFieldValue('fld-34f6d74d34354f63889f63a705b7d15f'); var country = ''; switch (issuing_state) { case 'Washington': case 'Oregon': case 'Texas': case 'Nevada': case 'Arizona': case 'Florida': case 'New York': case 'California': country = 'United States of America'; break; case 'New South Wales': case 'Victoria': case 'South Australia': case 'Tasmania': case 'Western Australia': case 'Northern Territory': case 'Australian Capital Territory': case 'Queensland': country = 'Australia'; break; case 'British Columbia': case 'Alberta': country = 'Canada'; break; } return country; } Autocomplete_Country();Basically in the
caselines you put each of the values you want to match and then set a variable (in my casecountry) to be the value you want. You can then return it and it’ll display.Here’s the same thing implemented as a map/dictionary:
function Autocomplete_Country_Map() { var issuing_state = record.getFieldValue('fld-34f6d74d34354f63889f63a705b7d15f'); var state_map = { 'Washington': 'United States of America', 'Oregon': 'United States of America', 'Texas': 'United States of America', 'Nevada': 'United States of America', 'Arizona': 'United States of America', 'Florida': 'United States of America', 'New York': 'United States of America', 'California': 'United States of America', 'New South Wales': 'Australia', 'Victoria': 'Australia', 'South Australia': 'Australia', 'Tasmania': 'Australia', 'Western Australia': 'Australia', 'Northern Territory': 'Australia', 'Australian Capital Territory': 'Australia', 'Queensland': 'Australia', 'British Columbia': 'Canada', 'Alberta': 'Canada' } return state_map[issuing_state]; } Autocomplete_Country_Map();It’s a little more concise though you’re writing down the country name each time so possible to get it wrong.
If you’re not after a direct 1:1 mapping of values between two fields, then we can continue down the earlier pathway. If you’re only after 1:1 this would work for you.
One last piece is if you want to make the field editable but still autocompleted, this script will handle that for you. In this case there are three fields: state, country and the script field. State and country are text fields whilst the script field is what we use to retain some state and set values. The script below handles this and includes a reference to itself to allow manual overrides to be preserved when autocomplete would overwrite:
function Autocomplete_Country() { var issuing_state = record.getFieldValue('fld-34f6d74d34354f63889f63a705b7d15f'); var issuing_country_id = 'fld-108b77c0b088457d90671dd71edf3247'; var issuing_country = record.getFieldValue(issuing_country_id); var autocomplete_country_id = 'fld-cf8a4c138a3a437991182f17000580d6'; var previous_country = record.getFieldValue(autocomplete_country_id); if (issuing_country && issuing_country != previous_country) { return previous_country; } var country = ''; switch (issuing_state) { case 'Washington': case 'Oregon': case 'California': country = 'United States of America'; break; case 'New South Wales': case 'Victoria': case 'Queensland': country = 'Australia'; break; case 'British Columbia': case 'Alberta': country = 'Canada'; break; } record.setFieldValue(issuing_country_id, country); form.saveAllChanges(); return country; } Autocomplete_Country();July 9, 2020 at 6:40 PM #41243In reply to: how to link fields when typing
Sam Moffatt
ParticipantThe complexity comes in that you need to encode the knowledge so that the computer can present it. Then once you’ve encoded that knowledge you need to access it to present it back to the user. Unfortunately Tap Forms doesn’t directly have an implementation that could hide that complexity from you so that means we’re implementing the complexity to make it look simple.
Let’s tackle the data modelling problem first for encoding which brands and which countries. The scripts I presented have a few different options, which is the most comfortable for you:
- form based: create a new form with two fields: one with the brand name and one with a comma separated list of countries (you could create a country pick list using the multi-value popover or checkbox options to make data entry easier)
- pick list based: create one pick list with a list of all of the brands in it and then for each brand create another pick list that defines the countries
- fully script based: encode everything into a single script file (probably a bad idea if you have a lot of data)
I think creating a new form to store it is probably the best path forward all told. Let me know which one of those approaches of storing the mapping data of “brand” to “country” makes sense for you and we can move forward with getting this sorted.
July 9, 2020 at 9:35 AM #41235In reply to: Hide fields with script
Daniel Leu
ParticipantYes, this can be done. Unfortunately, everytime you update your checkbox field, you have to click on
Recalculate Formulasto get the update.Here is my field script:
var hide_field_id = 'fld-xxx'; var target_field_id = 'fld-xxx'; var field = form.getFieldWithId(target_field_id); var status = ''; if (record.getFieldValue(hide_field_id)){ field.hideField = true; status = 'hiding field'; } else { field.hideField = false; status = 'showing field'; } document.saveAllChanges(); status;Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksJuly 9, 2020 at 7:17 AM #41234Topic: Hide fields with script
in forum Script TalkJean-Pierre Hermans
ParticipantIs it possible to hide different fields with a script? And if yes, can someone give an example because this is complete new for me.
I have a checkbox and when it’s checked then some fields in that record needs to be hided.
Thank you.July 9, 2020 at 3:22 AM #41233In reply to: how to link fields when typing
pierrot_rennes
ParticipantHi Sam,
Thank you for your answer
I went to see your code.
I’m looking for something simple, so I’m going to refine my search.
I have two selection lists: Brands and Countries.
For example, when I select the Ravensburger brand in field 1, field 2 displays the country France
Is it possible to define a script where each correspondence for brands and countries would be defined
Thank youJuly 8, 2020 at 9:29 PM #41229In reply to: how to link fields when typing
Sam Moffatt
ParticipantI’m not sure it’s possible to do that in Tap Forms with the default UI however I think you could easily create a form script with two prompters that did that for you. The input from the first prompter could be used to setup the second prompter which then sets the appropriate fields.
A while back I did a post with a couple of different options on how you can make it work.
July 8, 2020 at 3:04 PM #41220In reply to: Problem with If script
Daniel Leu
ParticipantHi Victor,
I noticed a few things:
- One of the pick list entries stated by a whitespace. You should remove that
- In your script, all branches need to be
else if - The address field selector should not be a checkmark, but a unique selector such as
Single Value Popover
With these changes, the script works for me.
Here is the code I’m using:
var address_field_id = 'fld-1f639ae503fe419b8473b02ea17d4ac4'; var address_field = record.getFieldValue(address_field_id); let result = ''; if (address_field=="newly identified - work address") { result = record.getFieldValue('fld-943ab25fd0de42e7b8d1e5487c6a358b'); } else if (address_field=="already identified - work address") { result = record.getFieldValue('fld-11915a3f275a4938949714a664dc40bf'); } else if (address_field=="newly identified - personal address") { result = record.getFieldValue('fld-0e624f31b7af41b18fcb0262a7ec2a0d'); } result;Please note that sometimes you need to press
Recalculate formulasto get the record’s fields updated.Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks -
AuthorSearch Results