- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2023 08:59 PM
I have created a script include in order to get the data from the custom table and set the value in the fields of "Impact" and "Urgency". The condition which I have put the output of the count of rows should be 1 but the output is 0.
setimpactur: function(){
var service_name = this.getParameter('sysparm_service');
var category = this.getParameter('sysparm_category');
var subcategory = this.getParameter('sysparm_subcategory');
var classification = this.getParameter('sysparm_classification');
var inci = new GlideAggregate('u_incident_priority_mapping');
inci.addAggregate('COUNT');
inci.addQuery('u_service',service_name);
inci.addQuery('u_category',category);
inci.addQuery('u_subcategory',subcategory);
inci.addQuery('u_classification',classification);
inci.query();
var recs =0
if (inci.next()){
recs = inci.getAggregate('COUNT');
gs.log("inside if count of rows "+recs);
}
gs.log("outside if count of rows "+recs);
return impact1;
}
Can anyone help ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2023 10:02 PM
So "classification " is the reason.
Check its data type and what did you pass to the query conditon may slove it!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2023 09:15 PM
Hi, what is impact1, its not defined anywhere in the code. Replace it with return recs if you want to return the records count.
Finally, your question is vague. Please provide more information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2023 09:21 PM
Do you means both "inside if count of rows" and "outside if count of rows" show 0 ?
The most possiable reason is there is no record met your query condition.
(like a normal sql , "count" always returs a record even there is no data met the search condition )
I suggest you to print all the parameters passed to this script include and then check them.
you can fire a normal query to find out if there are any records met your parameters.
And by the way "impact1" is not defined anywhere .
Did you return a wrong variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2023 09:53 PM
Yeah I tried checking the condition manually the answer of the "inside if count rows" and "outside if count rows" should "1" and I tried removing the classification condition, I got the answer as "6" which was supposed to be the answer. As soon as I am giving the classification condition the number of records in the output is coming 0 which is wrong the answer should be "1" because there is a record existing in the table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2023 10:02 PM
So "classification " is the reason.
Check its data type and what did you pass to the query conditon may slove it!