Client Script: redirect onLoad

tahnalos
Kilo Sage

Hello

We are trying to implement functionality which is supposed to ask for additional information before a Change is worked on.

The intent is that if the assignee is supposed to start work on the change, there may be some additional information that may need to be entered before the change can be worked on.

The idea is to have a redirect from the Change form to this separate form to log details, and once the details are all entered, it is supposed to redirect back to the Change Request form.   This form is supposed to be linked to the Change record as well.

I've seen action.setRedirect being used but that's more on the server side, and wondering if there is a client side redirect I can use?

Thanks.

1 ACCEPTED SOLUTION

Sorry, should be



g_navigation.openPopup( 'change_request.do?sys_id=-1&sysparm_query=parent=' + g_form.getValue('sys_id'), 'New Change');



New Change is the title of the Popup


The sys_id=-1 part opens a new change request


The parent= + g_form.getValue('sys_id') will auto populate the 'parent' field, so you can relate it back to the origin change.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

View solution in original post

10 REPLIES 10

Just want to clarify, the line should be


g_navigation.openPopup( 'change_request.do?sys_id=-1&sysparm_query=parent=' + g_form.getValue('sys_id') + 'New Change');




So if there is no record existing under the current circumstance, the popup will assume the record is new, correct?   Also, how does the 'New Change' work with it?   Logically, it means that the parent is pointing to "<sys_id>New Change".



Just wondering about clarification.



Thanks


Sorry, should be



g_navigation.openPopup( 'change_request.do?sys_id=-1&sysparm_query=parent=' + g_form.getValue('sys_id'), 'New Change');



New Change is the title of the Popup


The sys_id=-1 part opens a new change request


The parent= + g_form.getValue('sys_id') will auto populate the 'parent' field, so you can relate it back to the origin change.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Hi Paul.



So I'm finally getting this popup to work but I notice two things:



1) The ServiceNow Back button is visible (I want it hidden)


2) The Window is blank.   I likely need a separate view for this but wondering how I can point it to the correct view.



Thanks for your help so far.


Check out the openPopup documentation for the different options that are available


https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_GNV3-openPopup_S_S_S_B



The available options are here


Window.open() - Web APIs | MDN



The sysparm_view parameter sets the view


URL schema



Example


var url = 'change_request.do?sys_id=-1&sysparm_query=parent=' + g_form.getValue('sys_id') + '&sysparm_view=change;


g_navigation.openPopup(


        url,


        'New Change',


        'toolbar=no'


);



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

I'm talking about this back button:



find_real_file.png



The suggestion posited did not hide this.