Create KB from INC/RITM

CV1
Tera Contributor

Hello All,

We have a requirement where

  • Check if the INC or RITM is assigned to groupa or groupb.
  • When the INC/RITM is resolved /close completed, display dialog if they wnat to create a KB for that ticket
  • if user says yes then create KG or open KB portal with the specified category

 

Looking for help and steps to achieve this.

TIA

8 REPLIES 8

@CV1 

then simply handle this in the OOTB BR on incident table which does this

Add condition for Group A or Group B in the BR

AnkurBawiskar_0-1765950886536.png

 

💡 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

@CV1 

Hope you are doing good.

Did my reply answer your question?

💡 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

Hi @Ankur Bawiskar ,

Thank you for the Information . Few points :

 

  1. I created a client script for this purpose.(attaching screenshot).This worked for our requirement. (Attaching screen shot)
  2. Looking at other options more , noticed that in SOW, on opening an incident in related records, there is an option "Attached Knowledge".
    On selecting this option , there is a "New" button where you can create the KB. (Attaching screen shots. ) This feature is available for all groups .


  3. I followed the KB you provided, installed the plugin on our test instance to check if this option will address our requirement, and updated the Business Rule as suggested. However, I’m not seeing any changes.

    Currently, the Attach Knowledge option is still available to all groups, and the expected behavior is not occurring. Specifically, when the assignment group is GroupASN or GroupBSN and the incident is resolved, the system should prompt the user to create a Knowledge article. If the user selects “Yes,” it should open a new KB record with the Knowledge Base set to SN Doc.
    After installing the plugin and changing the BR by adding conditions, We don't see the required behavior. 


    Please let me know if something is missed?
    TIA



Sarthak Kashyap
Mega Sage

Hi @CV1 ,

 

I tried your problem in my PDI please check below solution 

 

I created a Client script OnChange - state and added below code 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var sysId = g_form.getUniqueValue();
	alert("Here");

    // Incident states
    if (newValue != 6 && newValue != 7){
		alert("State is " + newValue);
		return;
	}
        


    var ga = new GlideAjax('CreateKBArticle');
    ga.addParam('sysparm_name', 'shouldPromptKB');
    ga.addParam('sysparm_table', "incident");
    ga.addParam('sysparm_sys_id', sysId);

    ga.getXMLAnswer(function(answer) {
		alert("Inside Answer = " + answer);

        if (answer !== 'true')
            return;

        var ask = confirm("Do you want to create a Knowledge Article for this ticket?");

        if (ask) {
            openKB();
        }
    });

}


function openKB() {

    var url =
        '/kb_knowledge.do?sys_id=-1' +
        '&sysparm_query=' +
        'kb_knowledge_base=a7e8a78bff0221009b20ffffffffff17' +
        '^kb_category=ed1c2552ff0131009b20ffffffffff65' +
        '^source=' + g_form.getUniqueValue();

    g_navigation.open(url);
}

SarthakKashyap_0-1765950864305.png


I created a Script Include, client callable and added below code 

var CreateKBArticle = Class.create();
CreateKBArticle.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	shouldPromptKB: function () {

        var table = this.getParameter('sysparm_table');
        var sysId = this.getParameter('sysparm_sys_id');

        var gr = new GlideRecord(table);
        if (!gr.get(sysId))
            return "false";

        var allowedGroups = [
            '8a4dde73c6112278017a6a4baf547aa7',
            '287ee6fea9fe198100ada7950d0b1b73'
        ];//software, database

        if (!gr.assignment_group || allowedGroups.indexOf(gr.assignment_group.toString()) === -1)
            return "false";

        if (table === 'incident') {
            if (gr.state != 6 && gr.state != 7) // Resolved / Closed
                return "false";
        }

        if (table === 'sc_req_item') {
            if (gr.state != 3) // Closed Complete
                return "false";
        }

        return "true";
    },

    type: 'CreateKBArticle'
});

SarthakKashyap_1-1765950930271.png

 

Result

 

Currently this Inc is in IN Progress state when I change to Closed it ask me create KB Article 

SarthakKashyap_2-1765950957476.png

 

SarthakKashyap_3-1765950998383.png

It will navigate me to KB Article 

SarthakKashyap_4-1765951195207.png

 

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,
Sarthak