Suppress relational field value lookup

We have a relational field to a "Products" auxiliary table. When entering/updating an item in the primary project, we want the relational field to be searchable but only via the magnifying glass to the left of the field. We want to hide the "relational field value lookup" pop-up icon on the right, because end users do not have access to the auxiliary table data thus making the relational field value lookup meaningless and confusing. We do not want them to access that pop-up at all (for this particular field/project, not on a global/template level).  Any suggestions would be greatly appreciated.  Thank you.

Parents
  • Suggested Answer

    0

    Create a JS module with the code below.  Save it in Composer then associate it with any forms where you want to hide the "Advanced Search" button.  You can add a function call in that module or as an Action to your form.  The code will show or hide the "Advanced Search" icon for a single-relational field.  Note that this version only works with single-rels.

    To use the function: call it and pass the name of the single-relational field as the Display Name (like "Products"), the DB Name (all upper-case like "PRODUCTS"), the TS_ID of the field prefixed with "F", like "F1234") or the UUID of the field.

    The "code" format of this site messes up the indentation if the JS.

    • (edit 21-Jan-2025) -- fix typo in line 18 of script.

    
    

    // JS to hide the "Advanced search" for relational fields


    /*
    -- Author: $PauThompson@caci.com$
    -- Date: $1:23 PM 1/21/2025$
    -- File: $C:\Users\pauthompson\OneDrive - caci_caci\Documents\Src\js\Hide-Remove_Relational_Field_Advanced_Search.js$
    -- Script: $Hide-Remove_Relational_Field_Advanced_Search.js$
    -- Change: $03$
    -- Revision: $1.0$
    */

    // First param is field name. Will match on DBNAME (ALL UPPERCASE),
    // Displayname, field ID with "F" prefix (i.e. "F1234") or the field UUID.
    // Second param is a numeric flag to show (1), hide(0) or delete (-1) the
    // Advanced Search icon. The default is to hide it.
    // If you delete it you won't be able to show it again without reloading the page.
    const hide_remove_rel_fld_adv_search = (str_fldname,n_show_hide_remove=0) => {
    let obj_fld = _LookupField(str_fldname);

    if (obj_fld && obj_fld?.type=="single" && obj_fld?.subType=="relational") {
    let span_wrap = document.querySelector("span#" + _LookupField(str_fldname).fid + "\\.wrapper");
    if (span_wrap) {
    let a_advsrch = span_wrap.querySelector("tr>td input+a");
    switch(n_show_hide_remove) {
    case -1 :
    a_advsrch.remove();
    break;
    case 1 :
    jQuerySBM(a_advsrch).show(); // style="display: inline;"
    break;
    default :
    jQuerySBM(a_advsrch).hide() ; // style="display: none;"
    break;
    }
    } else {
    console.error(`Can't find SPAN element for "${str_fldname}" field on this form.`);
    }
    } else {
    console.error(`Please alert system Admins -- function: "hide_remove_rel_fld_adv_search" :: field: "${str_fldname}" not found or isn't Single-Relational`);
    // alert(`Please alert system Admins -- function: "hide_remove_rel_fld_adv_search" :: field: "${str_fldname}" not found or isn't Single-Relational`);
    }
    };

  • 0   in reply to 

    This is great! Thanks for sharing. Heart eyes

Reply Children
No Data