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

Voona Rohila
Kilo Patron
Kilo Patron

Hi asd

Try 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');
}

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Voona Rohila
Kilo Patron
Kilo Patron

Hi asd

can you keep logs and verify 'id' value?


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP