CSM Custom UI action creating a knowledge article fails due to permissions

garchoo
Tera Contributor

On a case table which extends sn_customerservice_case, I have a UI action button which calls a script include whose purpose is to create a knowledge article and populate it from the case fields. This action is failing with error "You do not have permission to contribute to this knowledge base." despite adding broad rights on the kb. I am logged in as admin. 

 

UI action:

var caseSysId = current.sys_id;
var newKbSysId = new CfiaCsmKnowledgeTools().createOEDArticleFromCase(caseSysId);
 

Script include:

var CfiaCsmKnowledgeTools = Class.create();
CfiaCsmKnowledgeTools.prototype = {
    initialize: function() {},
    
    createOEDArticleFromCase: function(caseSysId) {
        var caseGr = new GlideRecord('x_cfia_csm_int_case');
        if (caseGr.get(caseSysId)) {
            var kb = new GlideRecord('kb_knowledge');
            kb.initialize();
	    kb.kb_knowledge_base = '822e710693fce610c54bb1fb5cba10c';
            kb.short_description = caseGr.short_description; 
            kb.x_cfia_csm_int_u_kb_enquiry = caseGr.request;
	    kb.x_cfia_csm_int_u_kb_response = caseGr.approved_response;
            var newKbSysId = kb.insert();
            return newKbSysId;
        }
        return null;
    },
    
    type: 'CfiaCsmKnowledgeTools'
};

 

KB

Can Contribute = snc_internal

 

Any suggestions? I am very new to SN development. 

1 REPLY 1

garchoo
Tera Contributor

The issue turned out to be the "Application" field on the KB. The KB was created associated to "Customer Service" application instead of my custom application scope. When I recreated with my custom scope then the article creation succeeded.

It's still unclear why the article creation failed with the kb created under Customer Service, as I had implemented the cross-scope access to Global for creating kb_knowledge records. I assume some additional access needed to be provided between my custom scope and the Customer Service scope.