logo

NJP

Hide label of MRVS in native and portal

New article articles in ServiceNow Community · Dec 30, 2024 · article

Many a times there is a requirement to hide the label of MRVS in native and portal.

OOB there is no method to achieve this requirement.

Below script will help us achieve the same using DOM manipulation.

Ensure isolate script field is False so that DOM manipulation works. This field may not be on form but you can make it false from list.

function onLoad() {
    //Type appropriate comment here, and begin script below
    setTimeout(function() {
        var searchTitle = "Servers"; // give the MRVS Title here
        if (window != null) {
            // native
            $j(document).ready(function() {
                $j('span').each(function() {
                    if ($j(this).text() === searchTitle) {
                        $j(this).hide();
                    }
                });
            });
        } else {
            var aTags = this.document.getElementsByClassName("sp-field-label-padding ng-binding");
            for (var i = 0; i < aTags.length; i++) {
                if (aTags[i].textContent.toString() == searchTitle) {
                    aTags[i].style.display = 'none';
                    break;
                }
            }
        }
    }, 3000);
}

AnkurBawiskar_0-1735554884811.png

AnkurBawiskar_1-1735554884823.png

Output: Working fine in both native + portal

AnkurBawiskar_2-1735554884813.gif

Note: DOM Manipulation is not recommended practice

View original source

https://www.servicenow.com/community/service-operations-workspace/hide-label-of-mrvs-in-native-and-portal/ta-p/3137570