- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2025 10:58 PM
Dear experts,
I would like to ask how do I make the three related list tabs below that is bracketed in red to be mandatory according to the fields in the risk event form when a specific choice is selected? I know of the onchange or onLoad client script, but there is no option to make it mandatory how should I approach this matter?
function onLoad() {
if (g_form.getValue('u_parties_involved_in_affected_by_the_event').toString() == '1') {
alert('inside');
g_form.hideRelatedList('sn_risk_advanced_customer_info_breached_customer_s_involved_affected', true);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2025 11:16 PM
you cannot make related list mandatory using client script
You will have to use before update business rule on your main table, check if there are records in related list table or not
If not then stop the form submission
check this link and enhance
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2025 11:08 PM
Hi,
There is no OOTB scripts available to make Related lists mandatory. But You can take an approach of on before business rule by checking that there is at least one entry on the child tables related to the parent record and setabortaction to true in case there are no entries. you can trigger the BR based in field values selected in the record. Or you can trigger the same check via script include and an on-change client script and show a error message on the screen.
Please mark helpful if this approach works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2025 11:08 PM
Hi @ChuanYanF ,
It's not possible
there are issues with ask well let's say we were able to make it mandatory if the user clicks on the new button it's throws an error stating fill the mandatory info first (it's not possible but even if it were to work you are going to encounter this issue)
better create a before BR on the table and abort action if no related record is created and throw an error stating create a related record first
or
as soon as user updates the current record create a related record automatically by async or after BR
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2025 11:16 PM
you cannot make related list mandatory using client script
You will have to use before update business rule on your main table, check if there are records in related list table or not
If not then stop the form submission
check this link and enhance
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader