Cloned UI Action Not Working

SEDatSAS
Tera Contributor

I am new to SN development, so I am a little baffled at a behavior. My goal is to create a custom version of the Delete UI action that displays only on the Case view. I started by going to the UI actions and doing an insert / stay on the Delete form UI action for the global table. I then simply renamed my Delete to Delete SED, so I could tell them apart. I then excluded the Case form from original Delete UI action and included the Case form on the new Delete SED UI action.

 

I made no other changes, so I expected my Delete SED button to behave the same as the original Delete button. However nothing happens when I click the Delete SED button. Before I substituted my copy the original Delete button presented the cascade list and prompted for confirmation.

 

I know it must be something very simple that I am missing, but I would have expected the copied one to work.

 

SEDatSAS_0-1711570642580.png

var ajaxHelper;
var objSysId;
var tblName;
var dlg;
var returnUrl;
var fromRelList;
var module;
var listQuery;
var stackName = null;
var gotoUrl = null;

function confirmAndDeleteFromForm() {  
    objSysId = g_form.getUniqueValue();
    tblName = g_form.getTableName();
    fromRelList = g_form.getParameter('sysparm_from_related_list');
    module = g_form.getParameter('sysparm_userpref_module');
    listQuery = g_form.getParameter('sysparm_record_list');
    stackName = g_form.getParameter('sysparm_nameofstack');
    gotoUrl = g_form.getParameter('sysparm_goto_url');

    ajaxHelper = new GlideAjax('DeleteRecordAjax');
    ajaxHelper.addParam('sysparm_name', 'getCascadeDeleteTables');
    ajaxHelper.addParam('sysparm_obj_id', objSysId);
    ajaxHelper.addParam('sysparm_table_name', tblName);
    ajaxHelper.addParam('sysparm_nameofstack', stackName);
    ajaxHelper.setWantSessionMessages(false);
    if (gotoUrl && gotoUrl != "")
        ajaxHelper.addParam('sysparm_goto_url', setRedirectFields(gotoUrl));
   
    ajaxHelper.getXMLAnswer(getCascadeDelTablesDoneForm.bind(this), null, null);
}

function getCascadeDelTablesDoneForm(answer, s) {
   
    var ansrArray = answer.split(';');
    returnUrl = ansrArray[0];
    var objList = ansrArray[2];
    var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
    dlg = new dialogClass('delete_confirm_form');
    dlg.setTitle(new GwtMessage().getMessage('Confirmation'));
    if(objList == null) {
       dlg.setWidth(275);
    } else {
       dlg.setWidth(450);
    }
    dlg.setPreference('sysparm_obj_id', objSysId);
    dlg.setPreference('sysparm_table_name', tblName);
    dlg.setPreference('sysparm_delobj_list', objList);  
    dlg.setPreference('sysparm_parent_form', this);
    dlg.render();
   
}

function deleteCompleted() {
    dlg.destroy();
    var w = getTopWindow();
    cbField = w.document.getElementById('glide_dialog_form_target_' + tblName);
    if(cbField != null) {
        // this is a dialog form, make sure the completion callback is called
        cbField.value = 'sysverb_delete:' + objSysId;
        cbField.onchange();
       
       // dismiss the dialog form
       var elem = window.parent.document.getElementById('body_FormDialog');
       if (elem)
           new GlideWindow().locate(elem).destroy();
    } else {
        // this is a regular form, use the return URL to back to the correct view, where possible
        if (returnUrl != 'null') {
            window.location.href = returnUrl;
        } else {          
            // this is just the default case, in case everything else blows up, should never happen!
            window.location.href = window.location.protocol + '//' + window.location.host + '/' + tblName + '_list.do?sysparm_userpref_module=' + module + '&sysparm_query=' + listQuery + '&sysparm_cancelable=true';
        }        
    }      
}

// this logic is similar to that in RedirectTransaction.setRedirectURL
function setRedirectFields(gotoURL) {
    if (gotoURL.indexOf('$sys_id') > -1)
        gotoURL = gotoURL.replace(/\$sys_id/g, g_form.getUniqueValue());
   
    if (gotoURL.indexOf('$action') > -1)
        gotoURL = gotoURL.replace(/\$action/g, 'sysverb_delete');
   
    if (gotoURL.indexOf('$display_value') > -1)
        gotoURL = gotoURL.replace(/\$display_value/g, g_form.getDisplayValue());
   
    return gotoURL;
}

Thanks in advance for help.
 
Sue
3 REPLIES 3

nataliya_b
Tera Guru

if you clone your custom ui action, action name shall be different from the source. 

could the cause be - 2 ui actions with the same action name?

The same action name is not the issue. Changed it to delete_sed and updated all instances in the script. The Delete SED button still does not work.

僚汰秋
Tera Contributor

Has this been resolved?
If not, open the "sys_ui_action" table and check if the Isolate script field of the duplicated UI Action is set to false.
In my case, changing it from true to false made it work properly.