How do I hide a specific section in alm_hardware on the asset view?

Robert _ysakows
Tera Contributor

I have created a custom tab to show custom fields related to specific model category only. I want this tab to be visible only for that model category only. I've created UI Policy to hide the fields and it works, but it still shows empty tab (section). I've tried all AI suggestions and they all failed.

 

Anyone has a working and proved solution for that?

1 ACCEPTED SOLUTION

@Robert _ysakows 

section name is the name of that section in lower case and space replaced with underscore

Example: Resolution Information

g_form.setSectionDisplay('resolution_information', false)

55.png

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

6 REPLIES 6

Tanushree Maiti
Tera Patron

Hi @Robert _ysakows 

 

Use the following approach to hide/show the section through either a UI Policy or a Client Script.

A UI Policy is the recommended best practice.

 

g_form.setSectionDisplay('<Your_section_name>', false);

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Venky Kshatriy2
Mega Sage

Hi @Robert _ysakows 
Please use the script below in your onChange client script. This approach ensures that updates occur dynamically whenever the category changes.

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) return;

 

    if (newValue == 'hardware') {
        g_form.setSectionDisplay('custom_details', true);
    } else {
        g_form.setSectionDisplay('custom_details', false);
    }
}
If this response addressed your question, please mark it as Helpful and accept it as the solution.