Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

UI Action - Workspace Configurations

Jonathan102
Tera Guru

Hi all,

I am using the following script to create a UI Action/relate link and it works perfectly. "MY URL" actually contains a link, I just redacted it below.  My action name is kb_action.

 

function clientSideScript() {
var win = window.open("MY URL", "_blank");
win.focus();
gsftSubmit(bull, g_form.getFormElement(), "kb_action");
}
 
I know need to configure the workspace script to make it available in SOW but I need help with the script, please.
 
Thanks,
Jonathan 
4 REPLIES 4

Ankur Bawiskar
Tera Patron

@Jonathan102 

you want to open URL in new tab and submit the form

then use this in workspace client script

Ensure both the workspace checkboxes are checked

 

function onClick(g_form) {
    open("MY URL");
    g_form.submit('kb_action');
}

 

 

AnkurBawiskar_0-1738818727308.png

 

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

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

@Jonathan102 

Thank you for marking my response as helpful.

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

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

Thank you, Ankur!! That worked even though I had to change my script on the UI Action.  The one listed above worked earlier yesterday and then stopped working.  So, I changed the script to the following and it seems to work now.

function openWindow(){
top.window.open('MY_URL','_blank') ;
}
Even though I am not using the action in my script, what you suggested seems to work.  Let me know if you think I should make any changes, and I will accept this as my solutions.
 
Thanks!!
Jonathan 

One more question, do you know if there is a way to just open the URL in a new tab within SOW versus a new browser tab?

Thanks,

Jonathan