0

How can I sum the numerical values of the different customers I have chosen?

For example:

e006-M000021 total amount = 1,605.00+1605.00+1605.00+(-96.00)+...
e006-M000022 total amount = 5,964.85+(-1,075.00)+5.541.60+...

enter image description here

I will use the result as follows;

These records are also in my caller form. After selecting these records, I want the textbox in the new form I opened with the button to be

e006-M000021 total amount = XXX,
e006-M000022 total amount = XXX.

Now I can transfer the selected record and the values of the record to the textbox in the called form. But I am not able to sum the amounts corresponding to multiple and customer IDs.

My called form init method code:

    public void init()
    {    
       super();    
       if( element.args() && element.args().dataset() == tableNum(ARCSendSmsCustomerTmp))    
       {    
           Callertmp = element.args().record();    
       }    
       ////username and password are pulled from dealer parameters.    
       ARCDealerSmsParameters = ARCDealerSmsParameters::find();    
       ctrlUsername.text(ARCDealerSmsParameters.DealerUsername);    
       ctrlPassword.text(ARCDealerSmsParameters.DealerPassword);    
       ctrlSmsText.text(strFmt( @'SAYIN %1, %2 tarihi itibari ile toplam %3 TL gecikmiş ödemeniz bulunmaktadır.',Callertmp.CustName,Callertmp.DueDate,Callertmp.CurrencyAmount));    
       ctrlPhoneNumber.text(Callertmp.CustPhone);    
   }
Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50

1 Answers1

0

You can do this using the multiselection design pattern.

public void init()
{    
   ARCSendSmsCustomerTmp tmp;
   ARCSendSmsCustomerTmp callertmp = element.args().record();    
   FormDataSource fds = callertmp.datasource();
   Amount amount;
   super();    
   for (tmp = fds.getFirst(1) ? fds.getFirst(1) : fds.cursor(); fds; fds = fds.getNext())
   {
        amount += tmp.CurrencyAmount;
   }    
   ////username and password are pulled from dealer parameters.    
   ARCDealerSmsParameters = ARCDealerSmsParameters::find();    
   ctrlUsername.text(ARCDealerSmsParameters.DealerUsername);    
   ctrlPassword.text(ARCDealerSmsParameters.DealerPassword);    
   ctrlSmsText.text(strFmt("SAYIN %1, %2 tarihi itibari ile toplam %3 TL gecikmiş ödemeniz bulunmaktadır.", Callertmp.CustName, Callertmp.DueDate, amount));    
   ctrlPhoneNumber.text(Callertmp.CustPhone);    
}
Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
  • Thanks for your support but not the total amount of selected records. The amounts in the other records of the customer in the selected record must be collected. for example, there are 2 customers and a different number of records belonging to 2 customers. The amounts for both customers should be calculated differently. I tried this with the group by but without success. – Hakan Çelik Jun 22 '22 at 13:55
  • You cat do that in the inner of the for loop. Just append a string. – Jan B. Kjeldsen Jun 22 '22 at 15:56