Dashboard Designer - Multi Value choices

Hi,

I want to aggregate a multivalue choices colomn using this article :

But i don't understand where the colomn "_tags" is coming from ? This colomn has to be created ?

My colonm is named "Injury" (type choices ; multiple selections enabled).
So i tried to adapt the code present in your article :

handlers.requestSuccess = function(data, logger) {
//here we will create new set of items
var items = ;

//we go through each item from the list
data.items.forEach(function(item) {
    //if it has _Tags:
    if (item.Injury) {
    //for each tag:
    item.Injury.forEach(function(tag) {
        //we create new object and add it to our items:
        items.push({
        tag: tag.get_choices(),
        count: 1
        });
    });
    }
});

//we replace default items with our items:
data.items = items;
return true;

}

I tried to insert the function "get_choices" but it doesn't exist. Here is the error i get

Request failed: TypeError: tag.get_choices is not a function

I am sorry, i have no knowledge of java script.
Can you help me ?

Regards,

My bad, I corrected the function.
here is the good one in case of someone have the same problem :

handlers.requestSuccess = function(data, logger) {
//here we will create new set of items
var items = [];

//we go through each item from the list
data.items.forEach(function(item) {
    //if it has _Tags:
    if (item.Injury_location_TEST) {
    //for each tag:
    item.Injury_location_TEST.forEach(function(tag) {
        //we create new object and add it to our items:
      if (tag.toLowerCase().indexOf('not') === -1){
        items.push({
        tag: tag ,
        count: 1
          
        });
      };
    });
    }
});

//we replace default items with our items:
data.items = items;
return true;

}

I added this line in order to exclude all values containing "Not" in my case
if (tag.toLowerCase().indexOf('not') === -1)

My colomn is named : Injury_location_TEST

Regards,

1 Like