Tap Forms app icon half
Tap Forms Forum text image
Blue gradient background

Exchange tips and ideas with the Tap Forms community

Search Results for 'script'

Viewing 15 results - 841 through 855 (of 2,951 total)
  • Author
    Search Results
  • #47326

    In reply to: Help with a script 3

    Brendan
    Keymaster

    Oh, it’s just a matter of the wrong field IDs in the script. I guess I used an archive of the form you sent me a while ago to write the script. You also renamed the Kalvningar field to Antal kalvningar so that took me a minute to find it again.

    var kalvningar_id = 'fld-cdb4431a905f4b1dbaa750b07a63b6f1';

    When you see an error in the console, first check to make sure all the field IDs in the code match the field IDs on the left. You can select a field and see its ID below.

    #47317

    In reply to: Help with a script 3

    Daniel Leu
    Participant

    Hi Stig, instead of sharing a TapForms template, could you share a TapForms archive of a document that contains entries for just a few animals? I tried to see what the script does, but it returns an error. I don’t know if I missed to enter some data or if there is an issue with the script. Having a TapForms archive with known data would make debugging much easier. Thanks!

    Cheers

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #47315

    In reply to: Help with a script 3

    Stig Widell
    Participant

    Thank you Brendan for your efforts.
    Unfortunately I have to bother you once more because nothing shows up in the added script fields.
    Regards
    Stig

    Attachments:
    You must be logged in to view attached files.
    #47310
    Brendan
    Keymaster

    Hi Victor,

    It looks like I never really flushed that one out. It’s just returning exactly what you see. The search object with it’s ID and name.

    The primary use of AppleScript in Tap Forms would be to run a script within Tap Forms. And from there you can reference a search and get its records and perform some operation on the results.

    Thanks,

    Brendan

    #47309
    Brendan
    Keymaster

    Hi Sebastian,

    1. Custom layouts are fixed according to the x, y, height, and width settings you provide for it. There’s no workaround to make them dynamically sizeable. Sorry.

    2. The only way to show data from a Link to Form field in a Table or other Link to Form field’s table view is to add a Field Script which loops through all of the child records from the relationship and appends them into a big string to display. But even then there won’t be a whole lot of room because you can’t adjust the height of a row, only the width of the column. The Script Editor has a built-in snippet called Child Records Loop which is a starting point for building that kind of a function.

    Thanks,

    Brendan

    #47300
    Daniel Leu
    Participant

    It looks like @Sam has been busy lately. You might browse his GitHub repository where he has amassed different tools and scripts supporting TapForms: https://github.com/pasamio/tftools

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #47296
    Victor Warner
    Participant

    In the Applescript Tap Forms dictionary there is the following:

    search n, pl searches : A search item
    elements
    contained by forms.
    properties
    id (text, r/o) : The unique identifier of the search.
    name (text) : The name of the search.

    Is this for running a saved search, so that the result is that Tap Forms shows the records which match the criteria for the saved search?

    Also what is the syntax for this AppleScript item?

    Any help would be gratefully received.

    Victor Warner
    Participant

    Brendan,

    Thank you for the response. It has forced me to find a work around.

    I know it is possible with a File Attachment field to click on the Add File icon (+) and then add as many files as you wish. However this is not reachable by the menu or by the keyboard – only a mouse or trackpad will work.

    I post the following in case it is of use to someone else.

    The workaround provides:

    1. selecting the record in Tap Forms
    2. in Finder, selecting the files to be attached.
    3. running a Keyboard Maestro macro using the For Each action which:

    (a) copies the filename and path of each file selected to the system clipboard
    (b) runs the Tap Forms Form Script (via a short AppleScript script) on each filename with path copied ot the system clipboard

    This is has the benefit that it can be activated via a keystroke and there is no need to worry about the names of files being different.

    The final Tap Forms Form Script is as follows:

    `function Add_Alias() {

    var ClipBoardName = ”;

    var file_attachment_id = ‘fld-1f7f08ca22de4884b5a7aa6b52a74251’;

    var ClipBoardName = Utils.copyTextFromClipboard();

    var url = “file://” + ClipBoardName;

    console.log(url);

    record.addFileFromUrlToField(url, file_attachment_id);
    document.saveAllChanges();

    }

    Add_Alias();`

    The Keyboard Maestro script is attached as a PDF.

    Attachments:
    You must be logged in to view attached files.
    #47290

    In reply to: Help with a script 3

    Brendan
    Keymaster

    They’re basically the same scripts, just one returns the Djur-ID and the other returns the Birth Date. You can only return a single value at a time, so two scripts are needed. One for each field.

    #47288

    In reply to: Help with a script 3

    Brendan
    Keymaster

    Ok, so you need two Field Scripts. One to get the maximum birthdate value. The other to get the Djur-ID of the calf with the maximum birthdate value.

    Here’s the first one:

    function MaxBirthDate() {
    
    	var kalvningar_id = 'fld-9107a2de427749e18f024644fd3cc1ad';
    	var födelse_id = 'fld-8e0cd05ffe8d4603a8abb8ca4694b4ee';
    	var djur_field_id = 'fld-1bb0eb29c4774502bf91c318093ae4f6';
    
    	var kalvningar = record.getFieldValue(kalvningar_id);
    	
    	var maxBirthDate;
    	
    	for (var index = 0, count = kalvningar.length; index < count; index++){
         	var födelse = kalvningar[index].getFieldValue(födelse_id);
    
    		if (födelse) {
    			if (maxBirthDate == undefined || födelse.getTime() > maxBirthDate.getTime()) {
    				maxBirthDate = födelse;
    			}
    		}
    	}
    	return maxBirthDate;
    }
    
    MaxBirthDate();

    Set the Result type of the above Field Script to Date.

    function MaxBirthDateDjurID() {
    
    	var kalvningar_id = 'fld-9107a2de427749e18f024644fd3cc1ad';
    	var födelse_id = 'fld-8e0cd05ffe8d4603a8abb8ca4694b4ee';
    	var djur_field_id = 'fld-1bb0eb29c4774502bf91c318093ae4f6';
    
    	var kalvningar = record.getFieldValue(kalvningar_id);
    	var calves_id;
    	
    	var maxBirthDate;
    	
    	for (var index = 0, count = kalvningar.length; index < count; index++){
         	var födelse = kalvningar[index].getFieldValue(födelse_id);
         	var djur_id = kalvningar[index].getFieldValue(djur_field_id);
    
    		if (födelse) {
    			if (maxBirthDate == undefined || födelse.getTime() > maxBirthDate.getTime()) {
    				maxBirthDate = födelse;
    				calves_id = djur_id;
    			}
    		}
    	}
    	return calves_id;
    }
    
    MaxBirthDateDjurID();

    Set the Result Type of the above Field Script to Number.

    That should do it.

    Thanks,

    Brendan

    • This reply was modified 3 years, 6 months ago by Brendan.
    #47287
    Brendan
    Keymaster

    Hi Goutalco,

    I would recommend compacting your database documents and see if that brings the file size down. It should also improve the performance.

    The size of the document may initially increase after you compact it, but when you close and re-open it, the size will be smaller again.

    Go to the Preferences window and then the Maintenance tab to find the Compact Database button.

    As for CouchbaseLite, I don’t actually use JavaScript to fetch data from it within Tap Forms. I use a mixture of Objective-C and Swift. Even when you use the JavaScript API that I wrote, those just call out to Objective-C and Swift methods.

    As far as accessing the database outside of Tap Forms using CouchDB, that’s something that Sam is way more familiar with than I am. My goal for Tap Forms was to take all of that complexity of a database engine away from the user and give them an easy-to-use front-end to the more complex SQL engine that powers it.

    Thanks,

    Brendan

    #47284
    Goutalco
    Participant

    Hello everybody,

    I’am new to Tap Forms 5 and have so far created two databases, one for fitness purposes and another to support my research in medieval philosophy.

    The structure of the first database is almost complete with data that tracks my activities for roughly two weeks. Its size amounts to circa 30 MB (no images or attachments) with no performance issues.

    The basic structure of the research database that comprises raw textual data of some central sources (no images , media or attachments) is more or less complete although it will presumably evolve in course of the research. Its size amounts to roughly 1.5 GB. Opening the default layout of some complex forms starts to be delayed (≈ 2 seconds).

    I think the size of the research database in a real working state could be easily 5 GB. So I like to know if I have to expect performance issues in the future.

    My second question relates to the document store (CouchbaseLite?) that underlies Tap Forms 5. I guess the structure of this store is the reason that queries are done with JavaScript rather than SQL.

    As Sam Moffatt pointed out in this thread you can can replicate all of your data into a CouchDB instance and get access to it there. What is a good starting point for a layman to learn more about the basic logic and structure of NoSql and specifically JavaScript-style queries and CouchDB?

    Cheers

    #47283

    In reply to: Help with a script 3

    Brendan
    Keymaster

    Hi Stig,

    I’m sorry but I haven’t had any spare time to work on your scripts for you at this time. I’ve been too busy working on the next version of Tap Forms. And I’m sure that Sam has been pretty busy lately too.

    You’ve said that you want to get the maximum birth date value. But I don’t know which field represents the birth date in which form. It’s all in Swedish and I just don’t know which field you need to birth date on and I don’t know which form you want it displayed in.

    Maybe I can help if you can translate your form to English for me and re-upload it here. It would certainly make it easier for me to write a script for you.

    But if it starts to get complicated with lots of back-and-forth messaging, then I’ll have to bow out for now as I really need to get back to working on the next Tap Forms version.

    Thanks,

    Brendan

    #47275
    Paul Kettle
    Participant

    Hi Yvette
    You are correct I’m on an Apple Macbook – so I don’t know if its possible to do all of the things on IOS.
    The transaction history is a table that sits on the form, I added a text field and then changed it to a table. Once you have it inserted into the form you can then add columns in the same way as you would with Excel.
    I’ve attached my progress thus far and will try and develop it a little further as time allows. However I’ve no experience of writing scripts, so not sure how much of a help I’ll be to your grand plan.

    Attachments:
    You must be logged in to view attached files.
    #47274

    In reply to: Help with a script 3

    Stig Widell
    Participant

    HELP!
    Is there anyone who could help a farmer with no knowledge in scripts?

Viewing 15 results - 841 through 855 (of 2,951 total)