Publish UI action button Knowledge form

Joshuu
Kilo Sage

Hi All,

 

I have a requirement on the knowledge article form.

 

Whenever user clicks on the publish ui action button it always redirects to the list view. User wanted it to stay on the same page.

 

Below is the Publish UI action script.

 

function onPublishActionClicked() {
    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);
}

 could you please assist me on this.

 

Thanks & Regards. 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Joshuu 

Since that's OOTB UI action I will recommend not to update

but if you still require then add this line and see

function publish() {
    new global.KnowledgeUIAction().publish(current);
    action.setRedirectURL(current);
}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Joshuu 

This is a platform-defined and expected behavior, and I would recommend not changing it. Instead of creating technical debt, it’s better to educate users on how the platform is designed to work.

Also, consider the user flow: how will users return to the same page if they need to approve another article, then go back to the list view to search and publish?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@Joshuu 

Since that's OOTB UI action I will recommend not to update

but if you still require then add this line and see

function publish() {
    new global.KnowledgeUIAction().publish(current);
    action.setRedirectURL(current);
}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

SupriyaWaghmode
Kilo Sage
Kilo Sage

@Joshuu , 

 

There is  below line of statement is missing in server script. Please check the written answer by @Ankur Bawiskar 

action.setRedirectURL(current)

 

Please mark accepted solution if this resolves your query.

Thanks & Regards ,

Supriya Waghmode |ServiceNow Consultant