UI Action not working in workspace

Deep_D
Tera Contributor

Hi I have added a button to the form, it's working in form which redirects to other login page but the same button is not working in workspace. How to fix this?

 

var url = current.message_key;
action.setRedirectURL(url); 

 

Deep_D_0-1690257759593.png

 

Deep_D_1-1690257811656.png

 

Thank you

4 REPLIES 4

Sandeep Rajput
Tera Patron
Tera Patron

@Deep_D In order to make the workspace button work you need to put your code in Workspace Client Script as well. Please note that current is not available in client script so you need to fetch a field value via g_form.getValue('field_name') method.

 

Deep_D_1-1690257811656.png

Hi @Sandeep Rajput ,

I tried using below script but still it is not working.

function onClick(g_form) {
    var redirectURL = g_form.getValue('message_key');
//top.window.location = redirectURL;
g_navigation.openPopup(redirectURL);
 
Thank you

@Deep_D Can you put an alert inside the Workspace client script and alert the value of redirectURL. Via this exercise, you will get to know if the redirectURL variable holds the URL value or not.

Ankur Bawiskar
Tera Patron
Tera Patron

@Deep_D 

do this in workspace client script

I assume message_key field is of type URL and contains URL

function onClick(g_form) {
	var redirectURL = g_form.getValue('message_key');
	var win = top.window.open(redirectURL, '_blank');
	win.focus();
}

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