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 - 916 through 930 (of 3,053 total)
  • Author
    Search Results
  • #47467

    In reply to: Pictures for printing

    Brendan
    Keymaster

    Right now you would need separate photo fields to be able to print an entire sheet with different photos on it.

    As for referencing photo fields from a Calculation field, that’s not possible. But you can access the list of photos from a Script. But not the actual photos themselves. Just the metadata around the photos. Useful for building saved searches that might want to show only the records that are missing a photo.

    #47459
    Brendan
    Keymaster

    As Daniel said, and you can also hide the Script Field from displaying on the form. It will still activate when the field is changed in the UI.

    #47452
    Daniel Leu
    Participant

    Create a field with the type script and put it there. It will only be executed when the field web_site changes. At the end of the script, add a form.saveAllChanges().

    Cheers, Daniel

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

    #47451
    David Schwane
    Participant

    How do I implement field data scripting wihout looping? I understand field scripts and fields are watched via adding the field id. But how do I watch a field, change its value, and not cause a loop? I’m used to event driven functions where I could choose pre or post save, etc.

    Example:
    URL Field; If someone enters a URL with a query string, I want to strip out everything after the question mark. Where do i put this script?
    var web_site = record.getFieldValue('fld-xyz');
    var new_web_site = web_site.split('?')[0];
    record.setFieldValue('fld-xyz', new_web_site);

    #47445
    Daniel Leu
    Participant

    I use several scripts as infrastructure/include scripts. They only contain function or constant definitions. Then I use runScriptNamed() to include these functions. Later, whenever I need, I can call one of these defined functions from these include files.

    So for your example, define

    function formScript(abc) {
       console.log(abc)
    }

    Then from your calling script, you do

    runScriptNamed("myIncludeScript")
    and then later
    formScript("hello")

    Cheers, Daniel

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

    #47442
    Bernie McGuire
    Participant

    you mean the Form Script will have access to a variable declared in a Field Script function ??? are all your vars global? this sounds strange to me.

    What I understand is this:
    function FieldScript() {
    var xyz = ‘123’
    form.rundScriptedNamed(‘formScript’);
    }

    Then in the Form Script:
    function formScript() {
    var abc;
    //I can set abc = xyz
    abc = xyz;
    // and now abc will have ‘123’ in it ?
    }
    This doesn’t make any sence to me thinking about rules of encapusalation. Unless there is some type of ‘Global’ tag I need to use on the variable.

    Please help
    Thanks

    #47438
    Brendan
    Keymaster

    If you setup a variable and populate it before you call runScriptNamed() then you should have access to that variable from within the script you’re running. So no parameter required.

    #47434
    Bernie McGuire
    Participant

    I want to have a Form Level Script (DoSomething) that accepts an input parm ex DoSomething(‘abc’).
    I’d like to call this script from various field level scripts using runScriptNamed(‘DoSomething’) but I do not see how to pass the value of ‘abc’ into the script on the runScriptNamed call.
    Is it possible?
    Thanks
    Bernie

    #47432
    David Schwane
    Participant

    When a date field is changed with the date picker, the field script referencing that date field gets fired twice.
    Simple repro case, just a date field (date_last_used) and field script


    var date_last_used = record.getFieldValue('fld-xxx');
    console.log("Process Excecuted "+ new Date().toLocaleString())

    change the date manually and script fires just once.
    use the date picker, and script fires twice.

    Any suggestions for workarounds?

    Attachments:
    You must be logged in to view attached files.
    #47426
    David Gold
    Participant

    I’ve had a go at some Javascript but can’t get it to work. Basically I want it to take a search term off the clipboard, do a search and get the record ID for the found item and then copy that to the clipboard. It isn’t working so could someone tell me what I have done wrong?

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

    function search_records( haystack , needle ) {

    var name_id = ‘fld-90984efc3585456ab56763adff0a5228’;
    var rec;

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

    }

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

    }

    #47424
    David Gold
    Participant

    I don’t know JavaScript. I was wondering if there was a way on iOS to search a given form for a record (search either a given field or all fields – doesn’t matter) and then have tap forms open in that record? I was wondering if this is possibly via url scheme directly or if not by creating a script and then executing the script via url scheme. If the latter can someone help me with the JavaScript?

    #47423
    Daniel Leu
    Participant

    Looks like the context the script runs is different. Something Brendan will be able to answer.

    Cheers, Daniel

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

    #47420
    Daniel Leu
    Participant

    When you launch a script from a button, do you get any records when using search.getRecords()?

    Cheers, Daniel

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

    #47419
    David Schwane
    Participant

    Seeing some unexpected behavior upon further review.

    If I run the script from the Scripts menu, works fine. But fails from a button on a custom layout.

    As a test, I created a new script with a single line of code.

    console.log(typeof search);

    From Scripts menu, correctly returns object
    From button on form, incorrectly returns undefined

    This is on same search, same record, just running the script from menu vs button.

    #47416
    David Schwane
    Participant

    Is there any way to copy a photo field image to the clipboard via script?
    I can’t figure out how to retrieve the image from the blob object and then copy it to the clipboard.

    Basically need an image equivalent to Utils.copyTextToClipboard

    I can see the digest but that’s about it…


    var cover_id = 'fld-xxx';
    var cover = record.getFieldValue( cover_id );
    return cover[0];

Viewing 15 results - 916 through 930 (of 3,053 total)