Ui page redirection to current record

svani
Tera Contributor

Hi Everyone,

 

I am facing issues on redirection to the current incident page from the ui page once submitted , cancelled .

 

I have written the below code in html and client script still after each button clickable it is redirecting to the ui page itself not the current incident page.

 

Can anyone please help me here ti resolve thies.

<td colspan="2" style="text-align:left;padding-top:10px;">
                <button class="btn btn-primary" onclick="update_ticket()" style="margin-right:10px;">Link Jira</button>
                <button class="btn btn-primary" onclick="continueOK()" style="margin-right:10px;">Create Jira</button>
                <button class="btn btn-primary" onclick="return continueCancel()">cancel</button>
            </td>
 
client script: using glideajax and below is for call back function:
function myCallBack(response) {
        //Dig out the 'answer' attribute
        var ajaxcomplete = response.responseXML.documentElement.getAttribute('answer');
        alert(ajaxcomplete); //alert the result to make sure all is well.
        GlideDialogWindow.get().destroy(); //Close the dialog window
        var url =  window.location.href;
    
            top.window.location=url;
            //g_navigation.openPopup(url);
 

    }
//Cancel button script
function continueCancel() {

    GlideDialogWindow.get().destroy();
    var url1 =  window.location.href;
       
            top.window.location=url1;

}
function update_ticket() {

    GlideDialogWindow.get().destroy();
    var url2 =  window.location.href;
       
            top.window.location=url2;

}
 
 

 

3 REPLIES 3

Satishkumar B
Giga Sage
Giga Sage

Hi @svani 

 

try below updated code:

 

HTML and Client Script

HTML (UI Page):

<td colspan="2" style="text-align:left;padding-top:10px;">
<button class="btn btn-primary" onclick="update_ticket()" style="margin-right:10px;">Link Jira</button>
<button class="btn btn-primary" onclick="continueOK()" style="margin-right:10px;">Create Jira</button>
<button class="btn btn-primary" onclick="continueCancel()">Cancel</button>
</td>

Client Script:

// Function for updating ticket or any action
function update_ticket() {
GlideDialogWindow.get().destroy(); // Close the dialog window if any
// Perform your action (update ticket, etc.)
// After completion, redirect to current incident page
var url = window.location.href; // Get current page URL
top.window.location.href = url; // Redirect to current incident page
}

// Function for continuing after creating Jira
function continueOK() {
GlideDialogWindow.get().destroy(); // Close the dialog window if any
// Perform your action (create Jira, etc.)
// After completion, redirect to current incident page
var url = window.location.href; // Get current page URL
top.window.location.href = url; // Redirect to current incident page
}

// Function for canceling action
function continueCancel() {
GlideDialogWindow.get().destroy(); // Close the dialog window if any
// Perform any cancelation action (if needed)
// Redirect to current incident page after canceling
var url = window.location.href; // Get current page URL
top.window.location.href = url; // Redirect to current incident page
}

 

 

This approach should help ensure that after performing an action on your UI page, the page redirects back to the current incident page in ServiceNow as intended. Adjust the actions performed in each function (update_ticket(), continueOK(), continueCancel()) based on your specific requirements and workflows.

———————————————————-
If my response helps, please mark it as "Accept as Solution" and consider it "helpful."

Hi @Satishkumar B ,

 

i think its the same what i have written already but changed no luck.facing same issue.

 

thanks,

Sreevani

HTML (UI Page):

<td colspan="2" style="text-align:left;padding-top:10px;">
<button class="btn btn-primary" onclick="updateTicket()">Link Jira</button>
<button class="btn btn-primary" onclick="createJira()">Create Jira</button>
<button class="btn btn-primary" onclick="cancelAction()">Cancel</button>
</td>

Client Script:

function updateTicket() {
GlideDialogWindow.get().destroy(); // Close any open dialog window
// Perform update ticket action (replace with actual logic)

// Redirect to current incident page
redirectToCurrentIncident();
}

function createJira() {
GlideDialogWindow.get().destroy(); // Close any open dialog window
// Perform create Jira action (replace with actual logic)

// Redirect to current incident page
redirectToCurrentIncident();
}

function cancelAction() {
GlideDialogWindow.get().destroy(); // Close any open dialog window
// Perform cancel action (replace with actual logic)

// Redirect to current incident page
redirectToCurrentIncident();
}

function redirectToCurrentIncident() {
var url = window.location.href; // Get current page URL
top.location.href = url; // Redirect to current incident page
}