How to autofill new KA form with Incidident info from SOW with KCS Create Knowledge button

Marlon Dale
Tera Expert

When I click that Create Article button I'd like to configure which fields from incident autopopulate which fields in the create new article page. How do I do this? I'm trying to add new fields to the KCS Incident article template and autopopulate those new fields from data in the incident record.

5 REPLIES 5

Bert_c1
Kilo Patron

Seems you can add logic to the two functions (submitDirect() and submitCandidate()) in the UI Action named "Create Knowledge" defined in the  Incident Management for Service Operations Workspace application.

What I'm confused about is I'm opening a KCS OOB template. How does that UI Action pass parameters to that template(specified in my screenshot) when the UI Script of "Create Knowledge" only specifies either the kb_knowledge or kb_submissions tables?

The code is in that UI Action:

 

 

 

function submitDirect() {
    var kb = new GlideRecord("kb_knowledge");
    kb.source = current.sys_id;
    kb.short_description = current.short_description;
    kb.sys_domain = current.sys_domain;
    kb.text = "<p><strong>" + issueLabel + "</strong> - " + current.description + "</p> <p><strong>" + resolutionLabel + "</strong> - " + current.close_notes + "</p>";
    kb.workflow_state = 'draft';
    kb.kb_knowledge_base = gs.getProperty("glide.knowman.task_kb", "dfc19531bf2021003f07e2c1ac0739ab");
    kb.insert();
}

function submitCandidate() {
    var gr = new GlideRecord('kb_submission');
    gr.parent = current.sys_id;
    gr.short_description = current.short_description;
    gr.sys_domain = current.sys_domain;
    gr.text = "<p><strong>" + issueLabel + "</strong> - " + current.description + "</p> <p><strong>" + resolutionLabel + "</strong> - " + current.close_notes + "</p>";
    if (gr.insert())
        gs.addInfoMessage(gs.getMessage('KB submission {0} was created and attached to the parent record {1}', [gr.getDisplayValue(), current.getDisplayValue()]));
}

 

The lines above the two methods determine which method is called. Study Javascript if needed.

 

GlideRecord API creates the record in the database. Just add more lines for additional fields that you want.

 

 

// gr is the GlideRecord object for kb_knowledge record, current is GlideRecord object for the existing record.

gr.<field_name> = current.<field_name>;

 

 

I understand what GlideRecord does. My confusion is from my unfamiliarity with the knowledge article template forms. I see gr.text, but I don't see that field when I go to Form Builder on creating a new KA from a specified template. So I'm getting confused how the fields in my template are getting set when I don't see a field named "text"

Edit:

I've added screenshots from my PDI. You can see "Issue" and "Resolution" are auto-populated in SOW. When I got to view the form you can see their field names are "kb_resolution" and "kb_issue" so I'm confused where those names are in the script