Redirect to Task table not working

Sun11
Tera Contributor
We have two table: Request and Task Form. I used a UI action to show a modal for copying a record. Then, on the UI page, I copied the existing request to a new request. After meeting the condition, the task is created. On the task, after clicking 'OK' on the modal, it should redirect back to the task of the newly created request. However, this is not happening. I attached a screenshot where it is redirecting instead of the Task form.
 
Sun11_0-1719490635538.png
 
Client Script: UI Page
function submitCancel(){
    GlideDialogWindow.get().destroy();
    return false;
}

function submitChanges() {
    GlideAjax.disableSessionMessages();
    return true;
}
 

Processing Script: UI Page

processCopyRecord();

function processCopyRecord() {
    var copyRecordSysID = '';
    var grSourceRecord = new GlideRecordSecure(table);
    if (grSourceRecord.get(recSysID)) {
        var getSourceTable = grSourceRecord.getTableName();
        var grCopyRecord = new GlideRecordSecure('request');

        grCopyRecord.sys_created_by = grSourceRecord.sys_created_by;
        ....

        grCopyRecord.accomodation = task_requested_accomodation;
        copyRecordSysID = grCopyRecord.insert();

        var gr = new GlideRecord('task');
        if (gr.get('parent', copyRecordSysID)) {
            var sysid = gr.sys_id;
        }
        response.sendRedirect('task.do?sys_id=' + sysid); //original
 

    }
}
 

 

1 REPLY 1

Slava Savitsky
Giga Sage

Check if your sendRedirect call works if you temporarily remove all other code from the processCopyRecord function.