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.

  • 0  

    Hi. I believe you just need to uncheck the "Appears on lookup form and relational field value lookup" checkbox on the relational field's properties Options tab.

  • 0 in reply to   

    Hi Garry.  Thank you; that was my thought/hope as well, but it made no difference.  The icon to value lookup remains.  It's a thorn in my side.  Users click it but can't use the resulting pop-up, so it leads to confusion.

  • 0   in reply to 

    That option can also be overridden via the Application Administrator for Projects. Navigate to the Application Administrator, Projects, Default Fields, filter for your field, then click Show All Overrides. Then, check out each override listed and see which have the checkbox checked. 

  • 0 in reply to   

    Hi Garry.  Yep, I checked there.  Also unchecked at project level in app admin.  Support said no way to suppress and to try my luck here.  Thanks again.

  • 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 

    Thank you, PM.  I'm in 11.4.2 and can't get this to work.  I'm a complete JavaScript novice and think I'm getting tripped up on calling the script and passing the variable.  Could you please elaborate on that part?  I created the module with your verbiage but then can't get it applied to the field via form action.

  • Verified Answer

    +1 in reply to 

    Oops!  My mistake.  There was a couple missing chars in the line where the function was defined.

    Here's a pic of an action calling the JavaScript function plus a pic showing how it looks on the form during a transition.  You can compare the "Contact" field that has the "Advanced search" icon while it's missing for the "Company" field.

    NOTE: Opening the JavaScript debugger in your browser before starting the transition will show any errors.

    I can't claim that this will work for all the variations of forms. I tested with an SBM 11.8 non-legacy transition form.

  • 0 in reply to 

    It works on 11.4.2 legacy forms.  Thank you!!!

  • 0   in reply to 

    This is great! Thanks for sharing. Heart eyes