The CreatorCon Call for Content is officially open! Get started here.

How to hide an HTML element on load of a record producer?

Smith Johnson
Tera Guru

Hello,

I have a record producer and I want to hide the part that is marked with red, as shown below.

SmithJohnson_0-1686844878829.png

If I inspect the HTML, this looks like this:

SmithJohnson_1-1686845029355.png



How can I hide this part on load of the record producer??
An onload script will work, but how the code should look like for the aforementioned purpose?

Thank you,
Smith.




 

4 REPLIES 4

Tony Chatfield1
Kilo Patron

Hi, for a client script you would use setDisplay(), 

GlideForm | ServiceNow Developers

 

OOB examples

/catalog_script_client_list.do?sysparm_query=scriptLIKEsetDisplay&sysparm_view=

Hi,

unfortunately, what I want to hide is not a variable.

This is out of the box HTML element on a record producer on Shopping Hub.

That's why I need somehow to hide it with DOM manipulation.

Any ideas?

Riya Verma
Kilo Sage

Hi @Smith Johnson ,

 

Hope you are doing good.

Here's an example code snippet that demonstrates how to hide an HTML element using DOM manipulation:

var elementToHide = document.getElementById('elementID');
// Check if the element exists before attempting to hide it
if (elementToHide) {

  elementToHide.style.display = 'none';
}

 

And if this element is there only in widget and you cannot access in on load script then , You need to copy this OOB widget and change CSS of sn-panel header.

 

set the css as below :

.sn-panel-header{
display : none;
}

and then add this new widget in respective page designer. To open page designer you can directly right click on portal page by pressing control key.

 

 

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Hello @Riya Verma ,

thanks for your response. 

I think that this will not work in my case.

document.getElementById('elementID');

 
After inspecting the HTML, I don't see an id for my div element. 
I only see a class.

How the code should look like to get this element based on its class name?