- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2020 10:19 AM
Hello All, the aggregate count is not working as expected. Please help. The dot-walk addQuery should return a count of 100 for example, but I am getting 0 results.
var count = new GlideAggregate('alm_hardware');
count.addQuery('model.u_field','1111111');
count.addAggregate('COUNT');
count.query();
gs.log("This count is empty: "+count.getAggregate('COUNT'));
if(count.next()){
gs.log("This count is working: " +count.getAggregate('COUNT'));
gs.log('count');
}
Results:
*** Script: This count is empty: null
*** Script: This count is working: 0
*** Script: count
*** Script:
----------------------------------------------------------
The Second row should be a count of 100
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2020 12:21 PM
To help you, you can run this code:
var usedModels = 0;
var grModel = new GlideRecord('cmdb_model');
grModel.addQuery('u_field', '1111111');
grModel.query();
while (grModel.next()) {
var grHardware = new GlideRecord('alm_hardware');
grHardware.addQuery('model', grModel.getUniqueValue());
grHardware.query();
if (grHardware.next()) {
gs.log("The model: " + grModel.getDisplayValue() + " is used in Hardware");
usedModels++;
}
}
gs.log("There are: " + grModel.getRowCount() + ' Models available with 111111');
gs.log("There are: " + usedModels + ' Models used for Hardware with 111111');
Please share the log results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2020 11:00 AM
I may have a problem with the table. I just verified, the u_field is added to the layout, yet I cannot see the column on the list view. It should appear right after "Model Category"
And yes, I use the filter to filter by u_field = 11111 I get 0 results on the alm_hardware table. If I filter by the same criteria on the cmdb_model table I receive 100.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2020 12:03 PM
There are 100 hardware assets that have u_field populated with "11111". I cannot see this in the list view of alm_hardware. But I can see this from cmdb_model table.
So, am I not able to query the alm_hardware table to get the dot walk results from cmdb_model table?
cmdb_model table resuts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2020 12:10 PM
Check if any of those models are used in the hardware table.
The model can exist. But if it is not used for hardware, you will never find it in the hardware table. And that way any dot walking will not work, since any of those specific models (the models that have u_field=100) is not used.
If you can find a model out of those 100 in the Hardware table Model field, let us know. Because then there is something wrong.
If not, then it is just expected behavior.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2020 12:21 PM
To help you, you can run this code:
var usedModels = 0;
var grModel = new GlideRecord('cmdb_model');
grModel.addQuery('u_field', '1111111');
grModel.query();
while (grModel.next()) {
var grHardware = new GlideRecord('alm_hardware');
grHardware.addQuery('model', grModel.getUniqueValue());
grHardware.query();
if (grHardware.next()) {
gs.log("The model: " + grModel.getDisplayValue() + " is used in Hardware");
usedModels++;
}
}
gs.log("There are: " + grModel.getRowCount() + ' Models available with 111111');
gs.log("There are: " + usedModels + ' Models used for Hardware with 111111');
Please share the log results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2020 01:38 PM
*** Script: There are: 29 Models available with 44103112
*** Script: There are: 0 Models used for Hardware with 44103112