- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2016 03:39 AM
Hi,
I am working on map pages. I am trying to replicate the code in 'incident count by location' by giving a different table name but it does not seem to work. May i know where am i going wrong.
This is the code
var uri = gs.getProperty("glide.servlet.uri");
var count = new GlideAggregate('u_leads'); //u_leads is the table which has the field location
count.addAggregate('COUNT', 'location');
count.query();
while (count.next()) {
var loc = count.location;
var locCount = count.getAggregate('COUNT', 'location');
if (locCount > 0) {
var item = map.addItem(count);
item.latitude = loc.latitude;
item.longitude = loc.longitude;
item.marker_label = locCount;
var link = 'href=' + uri + 'u_leads_list.do?sysparm_query=location%3D' + loc;
item.html = '<a ' + link + '>' + loc.getDisplayValue() + ' (' + locCount + ') </a>';
item.icon = "/star.png";
item.icon_width = 20;
item.icon_height = 20;
}
}
Thanks,
Sam
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2016 04:39 AM
Hi Sam,
Not that used to the Aggregate method but here's what I ended up with:
I used a variable u_status that is true or false, so you can replace the true/false with the value of your Status variable(completed, open, closed....)
- var uri = gs.getProperty("glide.servlet.uri");
- var count = new GlideAggregate('u_leads');
- count.addAggregate('COUNT', 'u_location');
- count.query();
- while (count.next()) {
- var loc = count.u_location;
- var locCount = count.getAggregate('COUNT', 'u_location');
- var locOpen = 0;
- var locClose = 0;
- //COUNT THE STATUS = TRUE RECORDS
- var counto = new GlideAggregate('u_leads');
- counto.addQuery('u_location', loc);
- counto.addQuery('u_status','true');
- counto.addAggregate('COUNT');
- counto.query();
- if (counto.next()){
- locOpen = counto.getAggregate('COUNT');
- }
- //COUNT THE STATUS = FALSE RECORDS
- var countc = new GlideAggregate('u_leads');
- countc.addQuery('u_location', loc);
- countc.addQuery('u_status','false');
- countc.addAggregate('COUNT');
- countc.query();
- if (countc.next()){
- locClose = countc.getAggregate('COUNT');
- }
- if (locCount > 0) {
- var item = map.addItem(count);
- item.latitude = loc.latitude;
- item.longitude = loc.longitude;
- item.marker_label = (locCount);
- item.label_offset_left = -11000;
- item.label_offset_top = -2210;
- var link = 'href=' + uri + 'u_leads_list.do?sysparm_query=u_location%3D' + loc;
- item.html='<a ' + link + '>' + loc.getDisplayValue() + ' (' + locCount + ') - Open = ' + locOpen + ' - Close = ' + locClose + ' </a>';
- item.icon = "images/red_marker.png";
- item.icon_width = 50;
- item.icon_height = 50;
- }
- }
Thank you for marking the question as resolved
Harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2016 04:39 AM
Hi Sam,
Not that used to the Aggregate method but here's what I ended up with:
I used a variable u_status that is true or false, so you can replace the true/false with the value of your Status variable(completed, open, closed....)
- var uri = gs.getProperty("glide.servlet.uri");
- var count = new GlideAggregate('u_leads');
- count.addAggregate('COUNT', 'u_location');
- count.query();
- while (count.next()) {
- var loc = count.u_location;
- var locCount = count.getAggregate('COUNT', 'u_location');
- var locOpen = 0;
- var locClose = 0;
- //COUNT THE STATUS = TRUE RECORDS
- var counto = new GlideAggregate('u_leads');
- counto.addQuery('u_location', loc);
- counto.addQuery('u_status','true');
- counto.addAggregate('COUNT');
- counto.query();
- if (counto.next()){
- locOpen = counto.getAggregate('COUNT');
- }
- //COUNT THE STATUS = FALSE RECORDS
- var countc = new GlideAggregate('u_leads');
- countc.addQuery('u_location', loc);
- countc.addQuery('u_status','false');
- countc.addAggregate('COUNT');
- countc.query();
- if (countc.next()){
- locClose = countc.getAggregate('COUNT');
- }
- if (locCount > 0) {
- var item = map.addItem(count);
- item.latitude = loc.latitude;
- item.longitude = loc.longitude;
- item.marker_label = (locCount);
- item.label_offset_left = -11000;
- item.label_offset_top = -2210;
- var link = 'href=' + uri + 'u_leads_list.do?sysparm_query=u_location%3D' + loc;
- item.html='<a ' + link + '>' + loc.getDisplayValue() + ' (' + locCount + ') - Open = ' + locOpen + ' - Close = ' + locClose + ' </a>';
- item.icon = "images/red_marker.png";
- item.icon_width = 50;
- item.icon_height = 50;
- }
- }
Thank you for marking the question as resolved
Harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2016 05:39 AM
Thank you Harry for the help.