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 - 496 through 510 (of 3,012 total)
  • Author
    Search Results
  • #50057
    Seth Godin
    Participant

    It took me a lot of tries to figure out this easy hack, so I thought I’d save others the trouble.

    If you’re going to print out forms, it tempting to drag fields into place on a blank canvas and then format each field and hit print.

    The problems arise if you have content where the text is of unknown length. You don’t know how much space to leave, and it ends up being holey.

    The alternative is to simply type the name of each field in brackets, like this:

    [name]

    [description]

    [price]

    Which will cause the fields to stay stacked, regardless of how much data is in each one, flowing longer ones and filling space for the shorter ones.

    And you can format it, not just with fonts and sizes.

    Go to TextEdit, build into every Mac

    Make a new doc

    Don’t miss this step: under FORMAT, hit MAKE RICH TEXT

    (this cost me two hours of poking around)

    now, go ahead and put your bracketed fields in, and you can change the layout all you like.

    Then, copy what you’ve got, and paste it back into your form.

    Done.

    Hope this helps.

    • This topic was modified 2 years, 4 months ago by Seth Godin.
    #50041
    Victor Warner
    Participant

    Some time ago, I got help with how to import the data from a CSV file with a script (see the post at https://www.tapforms.com/forums/topic/using-javascript-to-import-csv-files/#post-45422).

    One of the fields in the CSV contains a date in the form “01/01/1963”, and the aim is to import it into a date field in the form.

    Although the script runs fine and imports the data in the CSV, the date field is not imported.

    Because of the way the script was written, I do not know how to change the format of the date field so that the date field is correctly formatted for import.

    Help would be very gratefully received.

     

    #50008

    In reply to: Open record as result

    David Gold
    Participant

    Hi Daniel (or OP)

    I would like to be able to do this also. I have some code below (not sure exactly how to insert a code block). I’m trying to do what you’ve said in line 11 with function show_name. Basically I want to be able to search the name field and when I get a result (whether multiple or single by selection in prompter) it then opens the record in Tap Forms. Can you tell me how to make it work?

    Really appreciate any help as my javascript knowledge is limited.

    var myForm = document.getFormNamed(‘Test’);
    var records = myForm.getRecords();
    var search_term = Utils.copyTextFromClipboard();
    var result_count = 0;
    var results = [];
    var results_name = [];
    var selected;
    function show_name( name ) {
        form.selectRecord(name[0]);
    }
    function copy_result_multiple( name ) {
        if ( name == true ) {
            console.log( ‘Index:’ + results.indexOf( selected ) );
            console.log( results_name[ results.indexOf( selected ) ] );
            show_name( results_name[ results.indexOf( selected ) ] );
        } else {
            console.log( ‘Cancelled’ );
        }
    }
    function multiple_results( all_results ) {
        let prompter = Prompter.new();
        prompter.cancelButtonTitle = ‘cancel’;
        prompter.continueButtonTitle = ‘Show Name’;
        prompter.addParameter(‘Select Result ‘, ‘selected’, ‘popup’, all_results)
        .show(‘Multiple Results Found’, copy_result_multiple );
    }
    function search_records( haystack , needle ) {
    var name_id = ‘fld-1acb38c0b51b44698849501407b51722’;
        var rec;
        for (rec of haystack) {
        var name = rec.getFieldValue( name_id );
        if (name && name.includes( needle ) ) {
                results.push( rec.getFieldValue( name_id ) );
                results_name.push( rec.getFieldValue( name_id ) );
                result_count++;
            } else {
            if (! name) {
            console.log(“Empty field: ” + rec.getUrl());
            }
            }
        }
        if( result_count == 0 ){
            Utils.alertWithMessage(“No Results”, “No results were found for the search term: ” + needle);
        }else if( result_count > 1 ){
            //multiple results
            multiple_results( results );
        }else{
            //single result
            show_name( results_name[0] );
        }
    }
    search_records( records , search_term );
    #50000
    Paul Hirst
    Participant

    If I’ve written a script to conduct a search and then at the end want to open the record that is the result of the search is there a way to do this? I have found the ability to print the result but that brings it up as a page to print rather than opens up the record?

    #49998
    David Gold
    Participant

    I’ve had a go at it cutting and pasting from some other scripts but can’t work out why it’s not working. Am getting an error in the console saying:

    var myForm = document.getFormNamed(‘Boral’);
    var records = myForm.getRecords();
    var search_term = Utils.copyTextFromClipboard();
    var result_count = 0;
    var results = [];
    var selected;

    function copy_name( name ) {
    Utils.copyTextToClipboard( name );
    }

    function multiple_results() {

    var joined = ‘–multiple_matches–‘;
    var res;
    for (res of results) {
    joined = joined +
    res.name;
    }
    copy_comments( joined );
    }

    function search_records( haystack , needle ) {

    var name_id = ‘fld-1acb38c0b51b44698849501507b51722’;
    var rec;

    for (const rec of haystack) {
    if ( rec.getFieldValue( name ).toLowerCase().includes( needle.toLowerCase() ) ) {
    results.push( { location: rec.getFieldValue( name_id ) } );
    result_count++;
    }

    }

    if( result_count == 0 ){
    console.log( ‘No results found!’ );
    }else if( result_count > 1 ){
    multiple_results();
    }else{
    copy_name( results[0].name );
    }

    }

    search_records( records , search_term );

     

    • This reply was modified 2 years, 4 months ago by David Gold.
    #49995
    David Gold
    Participant

    I don’t know JavaScript so I was wondering if someone could help me with a simple script for the iOS app that does a search of a database for a term called “input” of a database called Boral with a form called Boral Data and searched a field called Name (I can add the field ID where it is needed)?

    Any assistance would be much appreciated.

    #49991

    In reply to: Calc fields / Tab

    Brendan
    Keymaster

    Although you could do it with a Script field instead of a Calculation field:

    function Script() {
    
    // Replace with your own code
    var hello_world = "Hello\t\t\tWorld!";
    return hello_world;
    
    }
    
    Script();
    #49979
    Glen Forister
    Participant

    Earlier this week I made the same complaint, although a much longer explanation and description, but when I posted it, it disappeared, I thought maybe censored, but probably a glitch took me out.

    Yes, there needs to be an addition to the settings for the main program to enlarge all the program’s fonts.  I had to add an extra screen to my 14″ MacBook Pro because of this for all my programs, and it has helped a lot, but wasn’t enough help for Tap Forms.  I often have to work with my total screen zoomed in via Ctrl / touchpad sweep 2 finger sweep up to magnify to a point where I am comfortable.

    And, yes, this is a good program at a great price which almost replaces HanDBase which I had to move off of when Dave decided to quit.

    Thanks.

    • This reply was modified 2 years, 5 months ago by Glen Forister.
    #49936

    In reply to: Convert 2 fields

    Brendan
    Keymaster

    There’s two places for scripts. Either a Script Field, or a Form Script. Both have their uses.

    Script fields will get triggered to run whenever a value that the script field references is modified. Form scripts require you to manually run them.

    Each have their uses. If you want something to happen whenever you change a value, use a Script Field. You don’t have to even display it as you can hide it. it will work silently behind the scenes.

    If you had some sort of bulk process you’d like to do on all your records that you want to run manually, then use a Form Script.

    #49930

    In reply to: Convert 2 fields

    Michael Tucker
    Participant

    You can do it without scripts, I’ve attached a sample file.

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

    Hi Pinny,

    I’m sorry, but I don’t have an API in Tap Forms to get the current location via JavaScript. I’ll see about adding one.

    Thanks,

    Brendan

    #49918
    Brian Lennon
    Participant

    I have one more question, hopefully a straight-forward one and best illustrated by the accompanying screen grab.

    Field TRAININGold links to a form called TRAINING and contains the old data.  The TRAINEEid is the reference code for this person in the PERSONS form that holds these fields.

    Field TRAININGnew links to COURSES and is the intended destination of the new records.  I have manually inserted a record using the tick at the bottom and selecting course coded 38 from the COURSES form.  This is the action I want to script to complete data import and restructuring.

    The question:  If TRAININGnew links to courses as a join and sharing a common code, where is the common code in TRAININGnew?  In TRAININGold, the TRAINEEid (137905) linked to TRAINcode 38, 62 and 78.

    When I use the tick to show course 38 in TRAININGnew, it is obviously linking in some way to the TRAINEEid of 137905 but this shared link code is not visible in the linked table at TRAININGnew.  Somehow I reckon I need to incorporate this invisible link into my script that attempts to replicate the tick action.

    Once I have all the TRAININGold records transferred to TRAININGnew, my intention is to add new course records using the tick approach.

    Thanks again

     

     

    Attachments:
    You must be logged in to view attached files.
    #49915
    Brian Lennon
    Participant

    Many thanks Brendan – you capture exactly what I’m trying to do.  I will follow your suggestions.  I need to tune in more to the conventions of Javascript.

    Great support!

    Brian

    #49912
    Brian Lennon
    Participant

    Brendan – I feel I am presenting an issue that would probably use up too much of your precious time.

    I’m still struggling with the syntax of javascript and am probably trying something that’s too far beyond my present capabilities though  I did have success with some simpler scripts. (I feel like someone who has just started to learn English and is seeking help with an understanding of the grammar of Joyce’s Ulysses!)

    Anyway, will attach the form template as requested.

    My original database used 1:1 links from PEOPLE to TRAININGold (that just carried the person’s code and the course code) and this in turned linked to COURSES via the course code.  I’m aiming to simplify this so that PEOPLE links directly to COURSES.  With over 4,800 records in the database, a script is the only sensible way to process this import.

    I’m not sure how much the template communicates so here are the current linkages:

    Form PEOPLE > Field TRAININGold >>link 1:1 >> Form oldTRAINING (original data here)

    Form PEOPLE>Field TRAININGnew>>link many:many>>form COURSES (wanting structure to use this link)

    In the script I sent earlier I had changed the names of some variables to make them more understandable to myself and perhaps that was not the right thing to do.

    If you can give me a few pointes in the right direction I’ll struggle on in my learning process.

    Many thanks for your support.

     

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

    Hi Brian,

    So there are many issues with your code.

    • This syntax is incorrect unless you actually have a form named newTrainingId.
      • var newLinkedForm=document.getFormNamed('newTraining_id');
    • You weren’t using the variable newLinkedForm anyway in the rest of your code.
    • The line record.setFieldValue(newCode_id, oldTraining_code); is just setting the value on the same parent record over and over again.

    It would help me to better understand what you’re wanting to do if you posted your form template so that I can look at your form structure and see if I can help you with the script.

Viewing 15 results - 496 through 510 (of 3,012 total)