Post

2 followers Follow
0
Avatar

calculate the # of related items with specific status

Hello everybody, I'm trying to calculate the # of a related item that have status 1,2,3 etc..

 

how can i do that ?

fabien cohen

Please sign in to leave a comment.

2 comments

0
Avatar

Hi Fabien,

I think you find many examples in this forum for filtering/counting items by if-conditions. 
In general this is the way to do it:

var status = @All of your status field name in related app;
var count = 0;
for(var i = 0; i < status.length; i++){
     if(status[i] == "1"){
        count += 1;
     }
};
count

If you want to check for OR conditons (status == "1" OR status == "2" etc):

var status = @All of your status field name in related app;
var count = 0;
for(var i = 0; i < status.length; i++){
     if(status[i] == "1" || status == "2" || status == "3"){
        count += 1;
     }
};
count

Rainer
Rainer Grabowski 0 votes