Searching for a record using URL scheme or script

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Script Talk Searching for a record using URL scheme or script

Viewing 1 reply thread
  • Author
    Posts
  • June 2, 2022 at 6:09 AM #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?

    June 3, 2022 at 1:38 AM #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] );
    }

    }

Viewing 1 reply thread

You must be logged in to reply to this topic.