Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
July 27, 2020 at 8:28 AM #41548
Victor Warner
ParticipantT.L.
Thank you for the reply. I do in fact want to do fact I described as the two forms will after creating the new record in the Client Contact form will no longer need to be in context with each other.
The Client Enquiry form is there to capture details of a client enquiry, and if I am instructed I would like to then create a record in the Client Contact form without having to type some details again. But after that I will not be referring t the Client Enquiry form again.
Also using scripting will help me to learn JavaScript.
Any further help will be gratefully received…
July 27, 2020 at 6:48 AM #41546Topic: Tap Forms Javascript Scripting 101
in forum Script TalkT.L. Ford
ParticipantI just finished assembling
Tap Forms Javascript Scripting 101This beginner level tutorial:
* Teaches you how to read the scripts.
* Teaches you how to use the scripting interface.
* Teaches you how to apply the documentation.
* Teaches you how to write simple scripts.You do not need to have any experience programming or working with scripts.
http://cattail.nu/tap_forms/tap_forms_scripting_101/index.html
I wanted to answer some beginner scripting questions that I see in the forums and empower people to wield Tap Forms’ scripting power (it’s really cool!). I hope you find it helpful.
July 27, 2020 at 5:17 AM #41545Victor Warner
ParticipantI have two forms (Client enquiry, Client Contact). In the example both have the same fields in each:
First Name
Last Name
DescriptionWould I would like to do:
1. From a currently selected record in the Client Enquiry form;
2. Create a new record in the Client Contact form;
3. Put the values of First Name, Last Name and Description in the new record in the Client Contact form.Would I be creating a Form script rather than a field script?
Would I be starting from the Client Enquiry form?
Would be the code to do so?
Any help would be gratefully received.
July 27, 2020 at 3:39 AM #41544In reply to: Tap Forms for Magazines
pierrot_rennes
ParticipantHi Sam,
Really thank you very much for your help, your explanations and the script !!!
thank you very much and respect for the time you spent on thisI just integrated the new script and I made two or three tests quickly by modifying the properties of some fields as you explained to me
It seems to work fine and in the way that suits me ;-))I will experiment and test at the field level
And especially to learn the links of forms and controls ;-)I will also try to be inspired by your script code although the code is not my preference ;-))
Very long practice of IT but rather on the hardware side, network and troubleshooting …Thanks again for your help
BestJuly 26, 2020 at 1:17 PM #41536In reply to: Tap Forms for Magazines
Sam Moffatt
ParticipantWith the link you can absolutely fill it in from the Magazines form, that makes complete sense because when you add from the Magazines form, it autolinks the Magazine to the article for you similar to how the Table field operates.
The Articles form is just a more accessible version of the table field you created, I think under the hood Brendan modelled them the same way, it’s just that you don’t see the form as the field itself is the form. You could hide the Articles form if you wanted so you’d not see it in the forms list but would still be able to interact with it. I personally like having them all available but the option is there.
We can automate a lot of things using the calculation fields to pull data from the parent record. Tap Forms can’t give you a table view that has fields from either two different forms or fields from the parent form and rows in a table field. That’s in part where that Articles form comes in because we can reference that from other forms (Keywords in this case) and since it is linked to the Magazine form, we can use calculation fields in the Articles form to automatically replicate values from the parent Magazine form. The other advantage is that Tap Forms’ Link to Form JOIN field works on the form making it a little easier.
If you only want to link to the magazine plus magazine month and don’t need the article name or page details (essentially anything in your articles table or the articles form) in your keyword form, then you could change the Articles form (and link) back into just a simple table. I might have misunderstood along the way but I thought it was useful to see the article and page details for the keyword as well. That’s what a lot of this is predicated on is pulling all of those fields together into the keyword to make a table.
Looking at your second screenshot, if the Magazines link isn’t useful then you can safely remove it and for the articles link in your second screenshot if you click on the X button on the far right you can hide fields and reorder them (this also works in the multicolumn list view as well). Getting magazine month and number should be a calculation field that populates the value from the parent magazine form, this is just a matter of setting the fields up and making sure they have the right type (date for the month field and number for the number field [number should be the default]). If the calculation field is misbehaving, jump to the Articles form and click on the refresh icon on the bottom of the list view and it should recalculate the fields to update to the right value.
The challenge with automatically creating a keyword if one doesn’t exist is that we need to scan the keywords form to find what keywords exist and do an insert if one doesn’t exist. If I was using something like MySQL, it has functionality that is optimised to make this mostly cheap through it’s indexing system but Tap Forms isn’t built with a columnar index structure but is a document store. That means we need to build the index ourselves. Doing this each time you edit the keywords field is probably a little intensive and would slow Tap Forms down as your database scaled in keywords. I’m also going to make an assumption that you’re going to hit a threshold where adding a new keyword is a rare event rather than a common one, as it will be today. Given both of those, I went to create a form script that handles it. You could also modify it to be a script field (might even work as is) but again that would be a little disruptive to editing that might not be appreciated.
Here is a quick little form script that runs on the currently selected magazine record, scans the linked articles and checks the keyword table to see if it exists and creates a new keyword record if it doesn’t exist. It’s actually a slightly modified version of the earlier script, just without the link creation steps:
function Update_Keywords() { // 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 for the keyword field in the articles table. let keyword_id = 'fld-a75febca3ee54d2d9d77b8c176ac08db'; // Articles link field ID let articles_link_id = 'fld-9af3b672710949d8a96591e23ba5466b'; // 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). console.log("Finding keyword records..."); for (let keywordRecord of keywordForm.getRecords()) { console.log("Adding keyword: " + keywordRecord.getFieldValue(keywords_keyword_id)); kwRecords[keywordRecord.getFieldValue(keywords_keyword_id)] = keywordRecord; } console.log("Completed finding keyword records."); // Iterate over every record in this form... for (let sourceRecord of record.getFieldValue(articles_link_id)) { // Get the value of the keyword field... let keyword = sourceRecord.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); } // Log the keyword we processed, we're done! console.log(keyword); } // Save the changes. form.saveAllChanges(); } Update_Keywords();July 26, 2020 at 12:01 PM #41535In reply to: Question about Future Releases
Sam Moffatt
ParticipantThe Script Folder Access isn’t useful for putting scripts in but is another way of getting to the filesystem from outside of the App Store sandbox/container to import content. The sandbox limits your ability to arbitrarily read from the filesystem and this is a way of flagging a directory that can be accessed. I’m going to do an update to my receipt import process that uses it to import the images and blog about that when I get a chance because it’s a neat new feature. I personally wouldn’t use it to share scripts, the
form.runScriptNamedmakes more sense because it will be available on all locations for your document.The notes field is an implementation of UILabel/UITextView which is backed by an NSAttributedString that mostly has the capabilities of what you’d think of RTF (which was popular when it was originally created). It’s not a heavily featured control in many respects.
Personally I use web links to spin up a new browser instance instead of embedding inside the app directly.
July 26, 2020 at 6:36 AM #41526In reply to: Common Note for all records
Ron Statz
Participantmust be an easier way without getting into scripts. In a custom form, all that is required is to put the text on the form screen.
July 25, 2020 at 4:56 PM #41521In reply to: Tap Forms for Magazines
Sam Moffatt
ParticipantIt is in the Articles table (link) that I must enter, isn’t it?
What is the Article table for (Table0 in the form?The
Articles (Table)(typo with the closing bracket, missed the shift key) was there for reference, probably should have deleted it. Moving forward you’d want to use theArticles (Link)because it enables a little more precise referencing of the individual records.When I run the script, the new records are not added in the Keywords form (only in the Articles form)
Did I do something stupid or change something without realizing it?The script as written was targeted for the
Articles (Table)field, if you’re using theArticles (Link)then all you need to do is create a new record in theKeywordswith the value of the keyword that you’ve added then Tap Forms will automatically link everything together for you.For the Magazine Month field (calculation type), I cannot display it in a date format type MMMM YYYY
Ok, for the
Magazine Monthfield in theArticlesform, go into the calculation settings and set the Result Type option on the left hand side under the field list to Date. That will tell Tap Forms to treat it like a date value rather than a text or number value. The default result type for calculation fields are numbers and the default result type for script fields are text.When it’s set to Date then you can use the other field settings to control how the date field displays.
July 25, 2020 at 4:24 PM #41518In reply to: Question about Future Releases
Rocky Machado
ParticipantHi John – With javascript are you able to access the html tags (DOM objects)? what I am trying to achieve is generate a chart and then render it with an HTML tag (<DIV>). Is that possible in Notes field? How are you able to load a file inot the Notes field. I don’t see that feature?
Hi Sam – Have you written any sample code using the new Script Folder Access? could I load js files with the feature?
thanks,
rockyJuly 25, 2020 at 3:58 PM #41516In reply to: Common Note for all records
Sam Moffatt
ParticipantI think what you want done can be achieved by a script field that looks at the contents of another field to see what value it has in it and then outputs a result.
There was a post on how to link fields when typing which focused on mapping a value from one field into another one. It used
switchstatements via Javascript but a similar one could be done with nestedifstatements with Javascript regular expressions to match entries and values.Then the script field would display the same content on all records where the other text field contained a particular value.
July 25, 2020 at 6:02 AM #41503In reply to: Tap Forms for Magazines
pierrot_rennes
ParticipantHi Sam,
Sorry to ask you again
I made several tests with your form
But I think I didn’t get it all or something’s not working
We have three forms: Magazine, Keywords, Articles
The main form is Magazine so it is in this one that I enter all my articles with:
The title of the magazine
The number
The date of publication
Keywords
The pages
Subject titleIt is in the Articles table (link) that I must enter, isn’t it?
What is the Article table for (Table0 in the form?When I run the script, the new records are not added in the Keywords form (only in the Articles form)
Did I do something stupid or change something without realizing it?Another question :
For the Magazine Month field (calculation type), I cannot display it in a date format type MMMM YYYYTo sum up, the Keywords form is the most useful to me.
It allows me to consult the table which lists all the magazines for a specific keyword.I have attached the 3 forms that you had made at the beginning.
Thanking you for the time and the help you give me
Attachments:
You must be logged in to view attached files.July 24, 2020 at 12:21 PM #41499In reply to: Design Feedback
Rocky Machado
ParticipantHere is a the function I call. Basically I call another script that adds information to the markdown field. The reason I have the script broken out is that I call
applyStockPerformance(fldStockPerformanceKey,fldTradeId);multiple locations (i.e Upload Load process, refresh layout and when I’m expiring options module). Again thanks for the idea.document.getFormNamed('Script.Manager').runScriptNamed('Globals'); document.getFormNamed(FORM_TRADE_SUMMARY).runScriptNamed('Apply.Stock.Performance'); /** * * Refreshes the Trade Summary Layout. This module is called by the button that * that is on the Trade Summary Layout * */ function refreshTradeSummaryLayout() { let fldTradeId = record.getFieldValue('fld-5399c8a67ee44fc18239a890a5102d41'); let fldStockPerformanceKey = record.getFieldValue('fld-f5b68ce9937d4958a516862b502933b0'); //-- Run modules to update Markdown fields in Trade Summary form applyStockPerformance(fldStockPerformanceKey,fldTradeId); form.saveAllChanges(); } refreshTradeSummaryLayout();July 23, 2020 at 9:48 PM #41490In reply to: Question concerning Images
Brendan
KeymasterHi Rocky,
Script fields cannot display images, but you can write a script to add an image to a Photo field. There’s an API for getting an image from a URL:
record.addPhotoFromUrlToField(image_url, photo_field_id);July 23, 2020 at 11:03 AM #41482Topic: Question concerning Images
in forum Using Tap Forms 5Rocky Machado
ParticipantHi Team – Is it possible to load an image into a script field. I have a Trade Summary form and want to get the first image from my link form (Trade Journal form) and display it within my Trade Summary Layout form. Not sure if I am using the correct image properties, but here is a small sample of my code in the script field.
let linkTradeJournal = record.getFieldValue('fld-310f922806294fcda6e0215c29b7b1ff'); for (rec in linkTradeJournal){ //-- Only need the first entry of the record set let img = linkTradeJournal[rec].getFieldValue('fld-f2a5d1f9d7cc4ef9bc96e25f3aa3497b'); return img[0].mimtype; }thanks,
rockyJuly 23, 2020 at 8:41 AM #41478In reply to: Reminder Calendar
John Scoble
ParticipantThanks. Yes, it did take a lot of time, and sometimes I have to think back to work out how it calculates, if I want to make a change. So far, once I got it working, I left it alone. If it ain’t broke, don’t try to fix it! If anyone can find a shorter way to calculate it, that would be good.
Thanks for the script version. Although I used to code regularly in Visual Basic, I’ve never got into scripting. I must try it some time. I fear it won’t be for a while, as we are trying to downsize our housing at present, so I don’t have a lot of time for computing!
With best wishes, John
-
AuthorSearch Results