Script include and UI Action

Community Alums
Not applicable

Hi - The requirement is I need to show a UI button named "Email Article" on the knowledge article when there are PDF attachment attached to the article. 

 

Here is the script include and the UI action. The email client pop up is working but looks like the script include is not called. What is that I am doing wrong?

 

Script Include: 

AngelThyagaraj_1-1708987377052.png

var checkAttachments = Class.create();
checkAttachments.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    initialize: function() {},

    checkAttachment: function(kbID) {
        //var kbID = this.getParameter('sysparm_kbID');

        var att = new GlideRecord("sys_attachment");
        att.addQuery("table_name", "kb_knowledge");
        att.addQuery('table_sys_id', kbID);
        att.addEncodedQuery('content_typeLIKEpdf');
        att.query();
        if (!att.next()) {
            return false;
        }
        return true;
    },

    type: 'checkAttachments'
});

 

UI Action: 

 

AngelThyagaraj_0-1708987348358.png

function runClientSideCode()
{
	emailClientOpenPop('kb_knowledge', false, null, null, '24d933141be4421038bfc88c0a4bcb39');
	
}

 

 

1 ACCEPTED SOLUTION

Tony Chatfield1
Kilo Patron

Hi, what are the results of your debugging\diagnostics? Does your condition script run, are the conditions met?

is Boolean true returned to the condition check? Is your client side code triggered?

From a quick check I suspect your condition syntax may be incorrect as the script-include call is missing ()
new global.checkAttachments().checkAttachment(current.sys_id) == true;

View solution in original post

2 REPLIES 2

Tony Chatfield1
Kilo Patron

Hi, what are the results of your debugging\diagnostics? Does your condition script run, are the conditions met?

is Boolean true returned to the condition check? Is your client side code triggered?

From a quick check I suspect your condition syntax may be incorrect as the script-include call is missing ()
new global.checkAttachments().checkAttachment(current.sys_id) == true;

Community Alums
Not applicable

Thank you so much! It was the () parenthesis that was missing. Lit things make a huge difference 🙂