Hiding on RITM

jkhovren
Tera Contributor

I have a variable that is shown on the RITM in 2 different locations if a certain criteria is met and all the time in 1 of the 2 locations on the form.  When the criteria is not met I don't the variable to show on the RITM in the 2nd location.  I was coding on change: g_form.setDisplay('assignment_group', false); but this is blanking out both locations on the RITM.  I only want it to not show in 1 of the 2 locations.  The same is true of the Catalog Item.  This script 

g_form.setDisplay('assignment_group', false); is working for the Catalog Item but then it removes it from all the positions on the RITM. 

 

Is there a way to tell SN that based on criteria to not display a variable on the Catalog Item but do display it on the RITM.  It can show twice on the RITM. 

 

I just need to know how to not display on the Catalog Item but do display on the RITM. 

2 REPLIES 2

Kartik Magadum
Kilo Sage

Hello @jkhovren 

 

when you want to control the visibility of a variable differently on the Catalog Item and Requested Item (RITM) forms based on certain criteria, you can achieve this using client-side scripts. Your goal is to hide the variable on the Catalog Item form but show it on the RITM form when certain criteria are met.

You can use the onLoad client script to conditionally hide or show the variable. Here's an example script that demonstrates how to achieve this:

 

function onLoad() {
    // Define your criteria here. For example, check if a certain field has a specific value.
    var criteriaMet = g_form.getValue('your_criteria_field') == 'some_value';

    // Check if you are on the Catalog Item form.
    if (g_form.getTableName() === 'sc_cat_item') {
        // If the criteria are met on the Catalog Item form, hide the variable.
        if (criteriaMet) {
            g_form.setDisplay('assignment_group', false);
        }
    } else if (g_form.getTableName() === 'sc_req_item') {
        // If the criteria are met on the RITM form, show the variable.
        if (criteriaMet) {
            g_form.setDisplay('assignment_group', true);
        }
    }
}

 

Replace 'your_criteria_field' and 'some_value' with the actual field and value you want to use as your criteria. This script checks if you are on the Catalog Item or RITM form and then evaluates the criteria to determine whether to hide or show the 'assignment_group' variable accordingly.

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Thanks & Regards,

Kartik Magadum

Venkatesh_N
Tera Guru

Hi @jkhovren ,
The script suggested by @Kartik Magadum will solve your requirement. Additionally, If your variable is from a catalog item, you can write a catalog client script and untick the checkbox not to apply on RITM as shown in picture :

Venkatesh_N_0-1694770867424.png


Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks ,
Venkatesh Nekkanti