How to make the related list tabs for risk event shows only with certain condition

ChuanYanF
Tera Guru

Dear experts,

 

I am facing a problem where I am stuck in how to make certain related list tabs show when a certain field in the risk event form is selected then prompting the specific related list tabs to appear instead of all the tabs that is unrelated to appear simultaneously after submitting the risk event form. For example, I have created two custom tables one is payment-related fraud table, and another one is cyber incident table. In the risk event form, there is a field called risk event type so when I select payment-related fraud, then after submitting the payment-related fraud table will populate out and the cyber incident table will not, vice-versa. 

ChuanYanF_0-1740381217736.png

 

1 ACCEPTED SOLUTION

@ChuanYanF 

I assume you are using correct value to compare and given correct name of the related list

try this

function onLoad() {
    if (g_form.getValue('u_risk_event_type').toString() != '5') {
		alert('inside');
        g_form.hideRelatedList('sn_risk_advanced_payment_fraud_related_risk', true);
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@ChuanYanF 

you can use onload or onChange and based on field type show/hide the related list

 

if (g_form.getValue('risk_type') == 'your type value') {
    g_form.hideRelatedList('related_list_table_name', true);
}

 

If you have created a defined relationship then follow these steps

  • Go to any form where the related list is present.

  • Right-click to open the column context menu on the related list.

  • Select Configure > List control.

  • the ‘Related list’ field value from the list control. (Suppose - "Related_list_value" is the value)

  • Now the statement should be g_form.showRelatedList('Related_list_value');

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

It does not work as it appears to. This is my script. Please help.
function onLoad() {
if (g_form.getValue('u_risk_event_type').toString() !== '5') {
g_form.hideRelatedList('sn_risk_advanced_payment_fraud_related_risk');
}
}

@ChuanYanF 

I assume you are using correct value to compare and given correct name of the related list

try this

function onLoad() {
    if (g_form.getValue('u_risk_event_type').toString() != '5') {
		alert('inside');
        g_form.hideRelatedList('sn_risk_advanced_payment_fraud_related_risk', true);
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Rohit  Singh
Mega Sage

Hi @ChuanYanF 

 

You can create one On Load Client Script and use g_form.hideRelatedList API to hide the one of the related list depending upon the value of a field in the risk event field.

 

If my response helped, please mark it correct and close the thread so that it benefits future readers.

 

Regards,

Rohit