Hello,
I have a detail table with a detail record called “color”. I want to count how many times every color is found in the whole detail table. In my example there are only the colors “brown” and “blue”. My problem is, I don’t know how to change the record field value/content.
I tried the following way:
- I create two record fields (brown and blue) in the datamapper (Mode: Javascript; Expression: 0; Type: Integer; Data format: Treat empty as 0).
- I create a script in the design template to count how many times single colors could be found. Sadly it don’t work.
brown = 0;
blue = 0;for(var i in record.tables.detail){
if(record.tables.detail[i].fields.color == “brown”){
brown++;
}
else if(record.tables.detail[i].fields.color == “blue”){
blue++;
}
}record.fields.brown = varBrown;
record.fields.blue = varBlue ;
So I tried to output the results of varBlue and varBrown in html.
var test = varBrown+ " + " + varBlue ;
results.html(test);
That works fine.
How can I change the record field content/value?
Regards,
Thomas