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

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');
}
}

Hi @ChuanYanF 

 

Can you make sure that the related list name is correct. Go to List Control and check for related list name and make changes in your code accordingly. 

 

I have checked in my PDI for me it is working fine

 

RohitSingh3_0-1740388690237.png

 

RohitSingh3_1-1740388802423.png

 

MY PDI Snip

 

Impacted Services/CIs Related List Hidden

 

RohitSingh3_2-1740389016875.png

RohitSingh3_3-1740389060210.png

 

 

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

 

Regards,

Rohit