Prompt function in the time of Publish the KB article

Sukanta
Tera Contributor

Hi we have a requirement when user click on the publish button on kb article form it should ask user some input and that input will will on a coustom field on kb article form and   we are using promt to get input from user .

It is working but one issue is happening if user click on cancel button on the prompt it still publishing the article but we want to abort the action. Please see the below UI action script. (The requirement is to open a dialog box when we click the Publish button and whatever we write in the dialog box it will reflect in a field of KB_Version table. Also, if we cancel the dialog box or we keep empty dialog box the KB article will not be go into review state).

 
function onPublishActionClicked() {

 

    var response = prompt("Please write a comments here");
    if (response == '') {
        current.setAbortAction(true);

 

    } else {
        g_form.setValue("u_pr", response);
        gsftSubmit(null, g_form.getFormElement(), 'publish_knowledge');
    }
    if (g_form.getTableName() == "kb_knowledge_block")
        gsftSubmit(null, g_form.getFormElement(), 'publish_knowledge');
    else {
        var checkGuestAccess = new GlideAjax("KBAjax");
        checkGuestAccess.addParam("sysparm_type", "checkGuestUserHasAccess");
        checkGuestAccess.addParam("sysparm_id", g_form.getUniqueValue());
        checkGuestAccess.getXML(function(response) {
            var answer = '';
            if (response && response.responseXML && response.responseXML.documentElement)
                answer = response.responseXML.documentElement.getAttribute("answer") + '' == 'true' ? true : false;
            if (answer)
                renderModal();
            else
                gsftSubmit(null, g_form.getFormElement(), 'publish_knowledge');
        });

 

    }
}

 

function renderModal() {
    var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
    dialog = new dialogClass('confirm_publish');
    dialog.setTitle('Confirmation');
    dialog.setWidth(450);
    dialog.render();
}

 

if (typeof window == 'undefined') {
    publish();
}

 

function closeDialogAndPublish() {
    dialog.destroy();
    gsftSubmit(null, g_form.getFormElement(), 'publish_knowledge');
}

 

function publish() {
    new global.KnowledgeUIAction().publish(current);
}
0 REPLIES 0