Skip to main content
Known Participant
October 29, 2022
Answered

How to count multiple receipts

  • October 29, 2022
  • 1 reply
  • 537 views

I want to count the number of receipts I should have. I have a field for this, Fuel Receits. I have 6 lines containing 2 fields, Diesel and DEF. I want the Feul Receits field to add 1 if there is a value in either or both fields on each line. How do I accomplish this? 

This topic has been closed for replies.
Correct answer Nesa Nurani

If your fields are named "Diesel1-6" and "DEF1-6" use this as custom calculation script of "Fuel Receits" field:

var total = 0;
for(var i=1; i<=6; i++){
if(this.getField("Diesel"+i).valueAsString != "" || this.getField("DEF"+i).valueAsString != "")total++;}
event.value = total;

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
October 30, 2022

If your fields are named "Diesel1-6" and "DEF1-6" use this as custom calculation script of "Fuel Receits" field:

var total = 0;
for(var i=1; i<=6; i++){
if(this.getField("Diesel"+i).valueAsString != "" || this.getField("DEF"+i).valueAsString != "")total++;}
event.value = total;

Known Participant
October 30, 2022

Works great. Thanks.