- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 02:34 PM
Hello,
I have an ask to hide an embedded list onLoad() based off certain fields being populated. I am struggling to hide the embedded list. I have tried 2 different ways to hide the embedded list, but it is still not hiding. Please see below:
Method 1:
function onLoad() {
var isDiscontinued = g_form.getValue('u_is_discontinued');
if (isDiscontinued == 'yes') {
g_form.hideRelatedList("REL:ced561fe1b6edd94e0b2feeccd4bedc5");
}
}
Method 2:
function onLoad() {
// Saw this method on snguru website
var list = $$('div[tab_caption="Product Type"]')[0];
if(list.hasClassName('embedded')){
list.hide();
}
}
I have tried both methods, and both methods are not working.
Can someone please assist with this?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 11:42 AM
We were not able to make this work with the recommendations. What we winded up doing was creating a new section and then adding the embedded list to the section and used a client script to show/hide the entire section. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 03:47 PM
I don't see any reason why Method 1 wouldn't work - your code looks sound. So, basic troubleshooting - are you sure your 'if' statement is evaluating to true? That is, is the value of u_is_discontinued 'yes' or might it 'Yes' or '1' or 'true'? You've probably already checked that, but that would be my first step.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 07:30 AM
@Ron Legters - Thanks for your response! I checked all values and everything is there. The Embedded List is still displaying

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 03:43 PM
OK - I still want to know if your 'if' statement is evaluating to 'true'. Have you tried putting an info message of some kind in there, just to be sure you're getting into that block? It's kind of clumsy, I know, but I find it really helpful. something like:
var isDiscontinued = g_form.getValue('u_is_discontinued');
if (isDiscontinued == 'yes') {
g_form.addInfoMessage('in the if');
g_form.hideRelatedList("REL:ced561fe1b6edd94e0b2feeccd4bedc5");
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 05:11 PM
Is your embedded list name correct? - Product Type?
Also are you trying it on Service Portal?
Please mark this response as correct or helpful if it assisted you with your question.