- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2025 10:24 PM
Hello All,
I’ve added an 'Analyze' button to the Problem record form.
When clicked on that button, I want it to display all other Problem records whose short description or description contains keywords similar to those in the current Problem record.
Example: if the word 'Interface' appears, it should return all related Problem records with 'Interface' in their short description or description. How can I implement this functionality?"
Thanks,
Sattar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2025 10:40 PM
make the UI action as client side, something like this and it will show the list of problem within UI page
GlideDialogWindow: Popup Record List
UI Action: on problem table
Client - True
Onclick - showProblem()
Script:
function showProblem() {
var w = new GlideDialogWindow('show_list');
w.setTitle('Associated Problems');
w.setPreference('table', 'problem_list');
w.setPreference('sysparm_view', 'default');
//Set the query for the list
var desc = g_form.getValue('description');
var shortDesc = g_form.getValue('short_description');
var query = 'short_descriptionLIKE' + shortDesc + '^ORdescriptionLIKE' + desc;
w.setPreference('sysparm_query', query);
//Open the popup
w.render();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2025 10:32 PM
Hi @sattar3 ,
-Create a Script Include that will handle the logic for fetching related Problem records based on keywords. This Script Include will be called from the client-side when the 'Analyze' button is clicked.
var ProblemAnalyzer = Class.create();
ProblemAnalyzer.prototype = {
initialize: function() {},
getRelatedProblems: function(currentProblemId) {
var currentProblem = new GlideRecord('problem');
currentProblem.get(currentProblemId);
var keywords = currentProblem.short_description + ' ' + currentProblem.description;
var keywordArray = keywords.split(' ');
var relatedProblems = [];
var problemGR = new GlideRecord('problem');
problemGR.addEncodedQuery('short_descriptionLIKE' + keywordArray.join('^ORdescriptionLIKE'));
problemGR.query();
while (problemGR.next()) {
relatedProblems.push({
sys_id: problemGR.sys_id.toString(),
short_description: problemGR.short_description.toString(),
description: problemGR.description.toString()
});
}
return relatedProblems;
},
type: 'ProblemAnalyzer'
};
------------------------------------------------------
-Next, create a client script that will be triggered when the 'Analyze' button is clicked. This script will call the Script Include and display the related Problem records.
-Add the 'Analyze' button to the Problem record form and link it to the Client Script.
<button onclick="onAnalyzeButtonClick()">Analyze</button>
If my response helped, please mark it correct/helpful and close the thread so that it benefits future readers.
Regards,
Mohd Arbaz.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2025 10:33 PM
it's an easy requirement.
what script did you write so far and where are you stuck?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2025 10:40 PM
make the UI action as client side, something like this and it will show the list of problem within UI page
GlideDialogWindow: Popup Record List
UI Action: on problem table
Client - True
Onclick - showProblem()
Script:
function showProblem() {
var w = new GlideDialogWindow('show_list');
w.setTitle('Associated Problems');
w.setPreference('table', 'problem_list');
w.setPreference('sysparm_view', 'default');
//Set the query for the list
var desc = g_form.getValue('description');
var shortDesc = g_form.getValue('short_description');
var query = 'short_descriptionLIKE' + shortDesc + '^ORdescriptionLIKE' + desc;
w.setPreference('sysparm_query', query);
//Open the popup
w.render();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2025 10:50 PM
Hello @sattar3 ,
Are you looking for the similar functionality of "Related Search".
Change the filter of the "Related Search" to "Problem" instead of default "Knowledge" and it will give all the related Problem records which has Description with matching keywords.
If you need to add more fileds in search results,
- Navigate to All > Contextual Search > Table Configuration.
- Open the record for the table whose form you want to show the related search box on and configure the search fields.
If this solution helped resolve your issue, please consider marking it as helpful or correct.
This will assist others in finding the solution faster and close the thread.