UI Action Button

tzsabre
Tera Contributor

I am creating a Client-side button that will take users to a URL in a tab when it is clicked. I am having two issues with this.  The first is the button is not doing anything, below I put the code that it is using. I have tried the method below and using window.open() and neither have worked for me.

The second is that the button does not appear in the Employee Center and is only appearing when I click Open in Platform.

tzsabre_0-1694996822826.png

 

4 REPLIES 4

Vishal Birajdar
Giga Sage

Hi @tzsabre 

 

You can call the function in "Onclick" field on form instead of condition field.

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

RAMANA MURTHY G
Mega Sage
Mega Sage

Hello @tzsabre,

You have called openWindow() from the condition, You have to call it from Onclick. Please find below screenshot

RAMANAMURTHYG_0-1695011172968.png

You can also write openPopup() as below

g_navigation.openPopup(url, "Google", 'resizable,scrollbars,status');
// Google is name of window
// resizable, scrollbars, status are features of window

Please mark my answer helpful, if it helps you

Thank you

 

 

Please mark my answer helpful  & correct if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer

Sayali Gurav
Tera Guru
Tera Guru

Hello @tzsabre ,

 

Screenshot for reference. 

SayaliGurav_0-1695012856308.png

Script : 

function onClick(){
g_navigation.open('https://www.google.com');
}
 

If my answer helped you, please mark it as correct and helpful. 

Thanks & Regards,

Sayali Gurav

Ankur Bawiskar
Tera Patron
Tera Patron

@tzsabre 

the script looks good and it will work only in native.

It won't work in portal since client side UI actions don't work in portal.

You can make the UI action as server side and redirect using this

action.setRedirectURL(url);

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