Category: Scenario based QA - 3
Updated on: August 2, 2025  |  0

Scenario-Based Questions PART 3

🎓 Scenario-Based Question

Q1: Write a script to print the list of incidents grouped by assignment group.

Answer:

Below is a script using GlideAggregate to group active incidents by assignment_group and display their count:

var gr = new GlideAggregate("incident");
gr.addQuery("active", true);
gr.addAggregate("COUNT");
gr.groupBy("assignment_group");
gr.query();

while (gr.next()) {
  var countOf = gr.getAggregate("COUNT");
  var groupName = gr.getDisplayValue("assignment_group");
  gs.print(countOf);
  gs.print(groupName);
}
  

🧠 Explanation:

  • Filters only active incidents.
  • Groups results by assignment_group.
  • Uses GlideAggregate for performance and count aggregation.
  •  Prints the count and name of each group to the log using gs.print().

 

Q2: What is GlideAjax & Scratchpad in ServiceNow? Which one is better?

Answer:

🔄 GlideAjax

GlideAjax is a method used to make asynchronous server calls from a client script (like UI policy, client script, etc.).
This means you can fetch server-side data without reloading the page — think of it as making a quick phone call to get exactly what you need.

📝 Scratchpad (g_scratchpad)

Scratchpad is a JavaScript object that gets populated on the server side (usually via a Display Business Rule).
It sends preloaded data to the client when the form loads — like a sticky note handed to the client before they even ask.


🆚 Which one is better?

GlideAjax is usually better because it allows real-time, dynamic interaction without page reloads and is more scalable.
🧾 Use Scratchpad only for small, static data that's needed immediately when the form loads.

💡 "Use GlideAjax when speed matters. Use Scratchpad when simplicity is key." 🚀

Comments

No comments yet.


Log in to post a comment