Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Button to open specific view

asd22
Tera Contributor

Hello.

 

I have a button i want to open the view "registrering_av_hardware_ved_innkjøp" with. How do you script buttons in forms take you to a specific view?

 

 

 nyHW();
function nyHW()
{
//make the url to a new normal change
var url = sysparm_view="registrering_av_hardware_ved_innkjøp" ;
//Redirecting the user to the new url
action.setRedirectURL(url);
}

 

find_real_file.png

6 REPLIES 6

Community Alums
Not applicable

Hi @asd ,

The redirect needs to include the view.

function createRITM() {               //create the new Requested Item Record

  var newReq = new GlideRecord("sc_req_item");

        // set your fields here

        var id = newReq.insert();

        action.setRedirectURL('sc_req_item?sys_id=' + id + '&sysparm_view=YOURVIEWNAME');}

Other sample : action.setRedirectURL('sc_req_item.do?sys_id=' + newReq.insert + '&sysparm_view=Equip_Request');

To redirect to a specific view, that's where you'll have to build the URL including the sysparm_view= part I described above.

 

Mark my answer correct & Helpful, if Applicable.

Thanks,

Sandeep

Hello and thanks for the quick respons

 

Im having issues with this:

 

function nyHW() { //create the new Requested Item Record

var newReq = new GlideRecord("sc_req_item");

var id = newReq.insert();

action.setRedirectURL('sc_req_item?sys_id=' + id + '&sysparm_view=registrering_av_hardware_ved_innkjøp');}

 

as it wont open the veiw i have set. any ideas why?

Community Alums
Not applicable

You will have to debug this : action.setRedirectURL('sc_req_item?sys_id=' + id + '&sysparm_view=registrering_av_hardware_ved_innkjøp');

 

Ravi9
ServiceNow Employee
ServiceNow Employee

I think it will be easier if you share the whole screenshot of your ui action config instead of partial and also the result SS of the same