How to redirect to URL by using Ui Action?

JugantaN3978112
Tera Guru

Hi,

I want to redirect to some given URL by clicking on the 'Initiated Request Button' based on the selection of 

Task Type(drop down).

 

Script:

function redirectBasedOnTaskType() { // Get the current task record

var currentRecord = g_form.getTableName("x_bpin_ds_advisory_activity"); // Define the URL based on the task type var sn_redirectUrl = ''; if (currentRecord == 'x_bpin_ds_advisory_activity') { // Redirect URL for tasks sn_redirectUrl("ttps://go.bp.com/nbjty");

}

else if (currentRecord == 'x_bpin_ds_advisory_activity') { // Redirect URL for tasks sn_redirectUrl("https://go.bp.com/rHUZg"); } // Redirect the user to the URL } // Call the function when the button is clicked redirectBasedOnTaskType();

 

 

jugantanayak_0-1694684166989.png

 

jugantanayak_0-1694684635359.png

 

Thanks in advance.

 

 

1 ACCEPTED SOLUTION

JugantaN3978112
Tera Guru

Hi,

I am able to resolved my issue by using the script as mentioned below.

 

var tasktype = current.task_type;

    if (tasktype == "Web app scan") {

        action.setRedirectURL(http://www.xxxxx.com/mxxxxx.htm);

    }

    if (tasktype == "Infrastructure scan") {

        action.setRedirectURL(http://www.xxxxx2.com/mxxxx2.htm);

    }

    if (tasktype == "Mobile penetration test") {

        action.setRedirectURL(http://www.xxxx3.com/mxxxx3.htm);

    } 

    else if (tasktype == "Review by security architecture board") {

        action.setReturnURL(current);

        action.setRedirectURL(current);

        current.update();

    }

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@JugantaN3978112 

in client side you can redirect using g_navigation

g_navigation.open(url, '_blank'); // you can open in  new tab or same tab

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

JugantaN3978112
Tera Guru

Hi,

I am able to resolved my issue by using the script as mentioned below.

 

var tasktype = current.task_type;

    if (tasktype == "Web app scan") {

        action.setRedirectURL(http://www.xxxxx.com/mxxxxx.htm);

    }

    if (tasktype == "Infrastructure scan") {

        action.setRedirectURL(http://www.xxxxx2.com/mxxxx2.htm);

    }

    if (tasktype == "Mobile penetration test") {

        action.setRedirectURL(http://www.xxxx3.com/mxxxx3.htm);

    } 

    else if (tasktype == "Review by security architecture board") {

        action.setReturnURL(current);

        action.setRedirectURL(current);

        current.update();

    }