Category: Scenario based QA - 11
Updated on: August 8, 2025  |  0

Scenario-Based Questions PART 11

Scenario Based Question

Q1: Count and display Incident Categories (groupBy) from the Incident table using GlideAggregate.

💡 Answer:


var ga = new GlideAggregate('incident');
ga.groupBy('category');
ga.addAggregate('COUNT');
ga.query();

while (ga.next()) {
var category = ga.getValue('category');
var count = ga.getAggregate('COUNT');

gs.print('Category: ' + category + ', Count: ' + count);
}

 

 

text, letter

 

📄 Q2: Write a script to create a Known Error KB Article when a Problem record is marked as "Known Error" and map the Problem source.

💡 Situation: When the problem_state changes to Known Error, a KB article should be automatically created and linked to the Problem record.

💡 Answer (Business Rule Script):

function executeRule(current, previous /*null when async*/) {
if (current.problem_state == 'Known Error')

{
var kb = new GlideRecord('kb_knowledge');

kb.initialize();

kb.short_description = current.short_description;

kb.text = current.description;

kb.knowledge_base = 'Knowledge';

kb.workflow_state = 'published';

kb.u_problem = current.sys_id;

kb.insert();
}
})(current, previous);

Comments

No comments yet.


Log in to post a comment