onChange script error: TypeError: $$ is not a function function() { [native code] }

stacybentley
Tera Guru

Using the document https://www.servicenowguru.com/scripting/client-scripts-scripting/removing-form-buttons/ I created a client script to Hide the Submit button.

  • Table: Change Request [change_request]
  • UI Type: Desktop
  • Type: onChange
  • Field name: Type
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    if (newValue == 'Routine') {
        //Remove the 'Submit' button
        var items = $$('BUTTON').each(function(item) {
            if (item.innerHTML.indexOf('Submit') > -1) {
                item.hide();
            }
        });
    }

}

 

When the client script runs I get the error onChange script error: TypeError: $$ is not a function function() { [native code] }

Am I missing something?

Thank you,
Stacy

1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

 

If you want to use this script then you have to make sure that isloate script flag on client script is false. Which will allow you to use DOM manupiluation.


Thanks,
Ashutosh

View solution in original post

5 REPLIES 5

Jorn van Beek
Tera Guru

since a few versions ServiceNow removed default dom access.

Better way is modify the button conditions on when to show it or not.

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

 

If you want to use this script then you have to make sure that isloate script flag on client script is false. Which will allow you to use DOM manupiluation.


Thanks,
Ashutosh

Hi @Ashutosh Munot1 

Thank you for the answer that I was looking for.

Regards

mmk

Community Alums
Not applicable

Make sure that your untick the 'isolate script field. If it not available in the form go to form layout of the client script and add to client script form.

 

find_real_file.png