Search Results for 'script'
-
Search Results
-
Hi Everyone,
I am new to Tapforms and experimenting right now with JavaScript. Is there an option to run a Script automatically during the “normal” saving process?
Thanks for your Help.
Hannes
I would like to know if this will be possible sometime. Now I have to copy lists and paste them on another app. It would be better can print directly.
thank you.I am trying to learn to use loops in JavaScript combined with a saved search. I have been able to create a script that can obtain the required data from fields in records found by a saved search. However, I cannot write some data to a field for the records found by a saved search.
Could I have some help in identifying what is wrong or what needs adding. The sample database is attached.
// Fields var date_id = 'fld-93ed9225fc674e7c840266726e160538'; var first_name_id = 'fld-edfdac34b4de4df79e5aced3c3ddc9be'; var completed_id = 'fld-6a9df78c9df744e292f47e11077d3d6d'; var client_name_id = 'fld-ec4fb9b85cb54d52813a9cd69c08198f'; // Push variable var txt = []; // Getting saved search var saved_search = form.getSearchNamed('Completed'); // get the records for the saved search var dupes_search = saved_search.getRecords(); // Looping through the records for the saved search for (var index = 0, count = dupes_search.length; index < count; index++){ var dupes_search_details = dupes_search[index]; // getting the contents of fields var completed = dupes_search_details.getFieldValue(completed_id); var client_name = dupes_search_details.getFieldValue(client_name_id); // writing data to fields dupes_search_details.setFieldValue(first_name_id, "Johnny"); //dupes_search_details.setFieldValue(date_id, "2024-03-06"); // putting data from fields together txt.push((index+1) + ". " + client_name + " = " + completed + ", and the count of records found by saved search: " + count + "\n"); } txt.join(); console.log(txt);I have a script that concatenates a bunch of linked records as text and inserts the concatenated text into a field, so that I can easily scroll through a bunch of entries at once.
Currently, the script runs any time a linked field is updated, so every record has concatenated text stored in its designated field. But I don’t really need that text stored, since it’s redundant. It’s just useful to browse through the text when needed.
What would work nicely is if there was a script command to produce a modal or popover for viewing scrollable text that can be dismissed. The idea is that this would be ephemeral. Click a button to run the script, which concatenates the field and displays the full text for viewing, but doesn’t store it to the file.
The Prompter() class would work, except any text beyond a few lines is cut off and not scrollable.
Maybe this is such a unique request that it isn’t worth developing, but I thought I’d ask!
I would like to know, with a script, to add the value to a field in all the records in a linked form.
Eg first form (Clients) has a linked to Form (Work), and I wish to add a value to a field in the second form for the records related to a record in the first form, with a script. In the example database attached, adding ‘yes’ to the paid field in the Work form for any of the records linked to one of the persons in the first.
I am (vaguely) aware that I need to use a loop but cannot work out how to structure the script (or what actions/commands I need to use).
Any help gratefully received.
I have the following script which writes data from a .csv file to several fields. It does so by adding a new record and then writing the data to the fields. I would like to know how to do so to the currently selected record.
Any help would be gratefully received.
// this imports the Papa Parse script form.runScriptNamed('PapaParse'); // replace with your field ID's var date_of_invoice_id = 'fld-1b800a91fac14b329ef47d23c7cdacb0'; var date_paid_id = 'fld-60fa17dec2a24d9588ce4aafa3dccd5c'; var date_of_receipt_id = 'fld-9ed8f17873a642b4a2ee58ff24eba421'; var method_of_payment_id = 'fld-15b719109ab64053a5c46427622f81f5'; var payment_notes_id = 'fld-3a22501b3096443f8f92c6cf6c7e2de5'; function Import_Entries() { //let filename = "file:///Users/victor/vwdata/data/Notary/client database/not in use/FileMaker/notary/vPaymentDetails.csv"; let filename = "file:///Users/victor/Library/Mobile Documents/com~apple~CloudDocs/filedtoday/vPaymentDetails.csv"; let csvFile = Utils.getTextFromUrl(filename); if (!csvFile) { console.log("No CSV file?"); return } var output = Papa.parse(csvFile); // abort if there are any errors and log to console. if (output.errors.length > 0) { console.log(errors.join("\n")); return; } // read each line for (let line of output.data) { var newRecord = form.addNewRecord(); newRecord.setFieldValues({ [date_of_invoice_id]: line[0], [date_paid_id]: line[1], [date_of_receipt_id]: line[2], [method_of_payment_id]: line[3], [payment_notes_id]: line[4], }); //var job_completed_id = 'fld-ba0622aac1ea42ff9e5e9272c4314fa7'; //record.setFieldValue(job_completed_id,"Yes"); document.saveAllChanges(); } } // Import entries to form "Who" from filename "Whom.csv" Import_Entries("Notarial Act", "vPaymentDetails.csv");I was looking for a way, to collect all linked records of a 1:n related child form within one note filed of the parent form, in order to use these information for further purposes.Since I am NOT familiar with software development and an absolutely newbie to scripting, I was searching the TF forums, and with the help of theChild Records Loopsnippet and some tips and examples Brendan published here in the forum, I built a template for “Collecting Child Records in the Parent form”, that works as I expected (I am on iOS, but the template should work on mac as well).I’m quite sure there are many other “non-software-development” users with minor scripting skills, so I prepared the templates with “speaking” names in the hope that it is understandable even for newbies.Sorry programmers, this is a beginners guide ;-)There are 2 forms:– ParentForm (PF)– ChildForm (CF)Within the CF there are 4 different records (children), each with several properties. In one additional field “AllProperties” I put all properties for each child together (calculation field, separate field values are connected via “concat” formula).The PF is linked with the CF via “1:n relation”. Within this PF there are 2 records (Parent1 and Parent2). Via the field “children” (relation field to child form), each Parent is linked with 2 children.You can select the children with the “selection checkbox”.Then there is a calculation field “children count” which shows automatically the number of selected children for each Parent.Additionally there is a note field “CollectionOfChildren”, which automatically shows the information for the “AllProperties” field for all linked children, one line for each child. Since this is one field with one text (consisting of all properties of all linked children), the text is very clear at a glance and is e.g. printed very nice or could be used for further purposes.The information for this target “note field” is generated in a script field “ScriptCollectChildren”, which is hidden and thus not visible in the form (only when you edit the form).The script code is listed below, you do NOT have to adapt the code anyhow, just replace the three (red) fieldIDs (fld-4e07f10f46………) in the upper part of the code.You can use this forms and adapt it according to your needs, or you can implement such fields to your already existing forms, copy the script code, paste it into your script fiel and replace the field IDs with yours.I hope this template (and/or the script) helps some of you, at least if you are a “rookie” like I am.ScriptCode (@programmers: sorry for bad indentation, this was written in TF iOS app)function CollectChildren() {var parentform_Children_id = ‘fld-4e07f10f46c84c0c99c5ca723ee42ad5’;//table of sourcedata (1:n LinkField to ChildForm)var parentform_Children = record.getFieldValue(parentform_Children_id); //datasets of sourcedatavar childform_RequiredProperty_id = ‘fld-570a6131139842288f18683e91833f6c’;//field of interest of sourcedatavar parentform_CollectionOfChildren_id = ‘fld-557c63ce9156491e8f8891b00c0def5b’; //tagetfield for collected data from field of interestvar temp_CurrentChild = []; //array for collecting data//running through all datasets & collecting data into temp. arrayfor (var index = 0, count = parentform_Children.length; index < count; index++){var childform_RequiredProperty = parentform_Children[index].getFieldValue(childform_RequiredProperty_id);if (childform_RequiredProperty) {temp_CurrentChild.push(childform_RequiredProperty);}}//joining collected data from temp. array into temp. variablevar temp_ChildrenList = temp_CurrentChild.join(“,\r”);//writing joined collection from temp. variable into target fieldrecord.setFieldValue(parentform_CollectionOfChildren_id, temp_ChildrenList);return temp_ChildrenList;form.saveAllChanges();}CollectChildren();- This topic was modified 1 year, 8 months ago by . Reason: format optimization
- This topic was modified 1 year, 8 months ago by . Reason: tagged code as code
- This topic was modified 1 year, 8 months ago by . Reason: tagged code as code
- This topic was modified 1 year, 8 months ago by .
- This topic was modified 1 year, 8 months ago by .
Topic: Movie Library Template
Hello. I thought I’d share the movie library template I created to keep track of both my physical media (DVD, Blu-ray, etc.) and digital library. It’s essentially a main form with the basic movie information with two linked forms, one for physical media and one for digital. There is also a script to fill in the basic information using the TMDB Number/ID. I cobbled it together from these two topics: https://www.tapforms.com/forums/topic/watched-tv-shows/ and https://www.tapforms.com/forums/topic/get-movie-details-from-themoviedb-api-help-needed/. I know not this odd thing called JavaScript, but am a copy and paste demon, so thanks to everyone who contributed to this code. There are instructions in the script for use.
P.S. Programmers beware, I don’t know the indent rules, so it may cause an eye twitch.