Modify run script button

gauravagarw
Tera Expert

Hello, i want to modify the functionality of background script i want to modify the run script button but i don't know where to find that 

1 ACCEPTED SOLUTION

Chaitanya ILCR
Kilo Patron

Hi @gauravagarw ,

I don't think the button is available for configuration

I have tried something 
you can create a global UI script with something below
and select the element and add events to the elements something like click in this scenario

ChaitanyaILCR_0-1744282351845.png

script I used

window.addEventListener('load', function() {
    if (window.location.href.includes('sys.scripts.modern.do')) {
        $('MANDATORY').style.backgroundColor = 'red';
		$('MANDATORY').addEventListener('click',()=>g_form.addErrorMessage('hello'))
    }
});

 

result

 

ChaitanyaILCR_1-1744282471184.png

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

 

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@gauravagarw 

if you are thinking to change the color etc then not possible as it comes from platform level.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

no i don't want to change the color i want to perform some action before the actual scripts run in background 

@gauravagarw 

not possible, whatever you want to perform will be written as script

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

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

Chaitanya ILCR
Kilo Patron

Hi @gauravagarw ,

I don't think the button is available for configuration

I have tried something 
you can create a global UI script with something below
and select the element and add events to the elements something like click in this scenario

ChaitanyaILCR_0-1744282351845.png

script I used

window.addEventListener('load', function() {
    if (window.location.href.includes('sys.scripts.modern.do')) {
        $('MANDATORY').style.backgroundColor = 'red';
		$('MANDATORY').addEventListener('click',()=>g_form.addErrorMessage('hello'))
    }
});

 

result

 

ChaitanyaILCR_1-1744282471184.png

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya