Redirect to new tab/Window

kittu1
Giga Contributor

Hi,

 

I am trying to redirect to new page when clicked on the "Search Duplicates" button on the Knowledge form. Below is the code that I have used to redirect

 

 

gs.setRedirect("kb_find.do?sysparm_search=" + encodeURI(current.short_description) + "&sysparm_operator=IR_OR_QUERY&sysparm_order=relevancy&sysparm_stack=no&sysparm_query=sys_id!=" + current.sys_id);

 

I tried using the window.open() but it did not work. Can anyone please help.


Thanks,

Vamsee.

1 ACCEPTED SOLUTION

Hi Vamsee,



Firstly you need to call this function in the onclick function field which gets displayed when you select "client", secondly current doesn't work when you select "Client" option, you can use g_form.getUniqueValue() instead of current.sys_id and g_form.getValue("short_description") instead of current.short_description.


Once you have the URL in place, I suggest that you try to navigate to it through your browser and make sure that it is navigating properly. Also alert the fields that you are using in the URL to make sure that the fields are coming up properly.



Thanks & Regards,


Hari


View solution in original post

10 REPLIES 10

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Vamsee,



Please refer section 6 on this for further details


UI Actions - ServiceNow Wiki



Thanks,


Pradeep Sharma


harikrish_v
Mega Guru

HI Vamsee,



You can use window method only if the "Client" option is checked in your UI action. Otherwise, you can use the action.setRedirectURL('<your_url>'). You might have the wrong URL here, so I suggest that you look into this wiki link and make sure that your URL is proper:-Navigating by URL - ServiceNow Wiki



Thanks & Regards,


Hari


Hi Hari,



I have used the below script with the "Client" checkbox selected. It did not work.



function kbfunc(){


var url = "kb_find.do?sysparm_search=" + encodeURI(current.short_description);


      url+= "&sysparm_operator=IR_OR_QUERY&sysparm_order=relevancy&sysparm_query=sys_id!=" + current.sys_id;


window.open(url,"_blank");


Hi Vamsee,



Firstly you need to call this function in the onclick function field which gets displayed when you select "client", secondly current doesn't work when you select "Client" option, you can use g_form.getUniqueValue() instead of current.sys_id and g_form.getValue("short_description") instead of current.short_description.


Once you have the URL in place, I suggest that you try to navigate to it through your browser and make sure that it is navigating properly. Also alert the fields that you are using in the URL to make sure that the fields are coming up properly.



Thanks & Regards,


Hari


Hi Hari,



It worked. Thank you very much.



Regards,


Vamsee.