0

This code works erratically sometimes it works and other times it doesn't

This code works erratically sometimes it works and other times it doesn't.

delete (select 'Evaluation table');
let myY := year('Evaluation Date');
let myYM := yearmonth('Evaluation Date');
let datorder := ((select Dates where 'Cod Nr' != 1 and yearmonth('Final Date') >= myYM) order by 'Final Date');
for fY in range(myY, year(today()) + 1) do
    let myArray := for fM in range(1, 13) do
            cnt(datorder[year('Final Date') = fY and month('Final Date') = fM])
        end;
    let newRec := (create 'Evaluation table');
    newRec.(
        Year := fY;
        Jan := item(myArray, 0);
        Feb := item(myArray, 1);
        Mar := item(myArray, 2);
        Apr := item(myArray, 3);
        May := item(myArray, 4);
        Jun := item(myArray, 5);
        Jul := item(myArray, 6);
        Aug := item(myArray, 7);
        Sep := item(myArray, 8);
        Oct := item(myArray, 9);
        Nov := item(myArray, 10);
        Dec := item(myArray, 11)
    )
end

Some idea

9 replies

null
    • Rafael Sanchis
    • Rafael_Sanchis
    • 9 mths ago
    • Reported - view

    The idea is this, but continues erratical

    • Fred
    • 9 mths ago
    • Reported - view

    Can you be more descriptive by what you mean "erratically"?

    Looking at the code it looks like it is doing what you are asking with the data provided.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 9 mths ago
      • Reported - view

       

      Hi Fred

      The script is on botton, when I insert data and click the botton the data in 'Evaluation Date' no Update, but when close the DB and open again and click the Button Update perfect. The same on Web and Android

      • Fred
      • 9 mths ago
      • Reported - view

      I don't seem to have that issue. I'm using Public cloud.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 9 mths ago
      • Reported - view

       

      yes me to Too extrange ok Thanks Fred

      • Rafael Sanchis
      • Rafael_Sanchis
      • 9 mths ago
      • Reported - view

       

      https://youtu.be/T6Uu3Q1Aodk?feature=shared

      A small video to see the problem. 

      The problem on Web, and Android, and Public Cloud

    • Fred
    • 8 mths ago
    • Reported - view
     said:
    A small video to see the problem.

     I don't see a problem. The first time you click the button your are on a record with Cod hr = 600 with a final date of 12 Dec 2024. Then you open and close the DB and then click on a record with Cod hr = 17 that has a final date of 29 Nov 2023.

    You have this on line 4 of your button:

    let datorder := ((select Dates where 'Cod Nr' != 1 and yearmonth('Final Date') >= myYM) order by 'Final Date')
    

    The first time you click the button with:

    Final Date = 12 Dec 2024

    Evaluation Date = 2 Dec 2024

    the datorder will find records in Dates with a yearmonth() that is equal to or greater than 2024/12. From the looks of it you only have 3 records that match.

    The second time you click on the button with:

    Final Date = 29 Nov 2023

    Evaluation Date = 20 Nov 2023

    the datorder will find records in Dates with a yearmonth() that is equal to or greater than 2023/11. It looks like you have records from 2023 and 2024 that match this and thus you get more data.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 8 mths ago
      • Reported - view

       

      Yes now understand, excelent explained.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 8 mths ago
      • Reported - view

       

      And Resolved 👍

Content aside

  • Status Answered
  • 8 mths agoLast active
  • 9Replies
  • 55Views
  • 2 Following