darkoGj
19th September 2023, 14:37
Hi,

I have few fields in my report script and assigned them some logic in 'before.display' section.

field.free.capacity:
before.display:
free.capacity = txkop201.cale - required.capa


field.required.capa:
before.display:
required.capa = txkop201.capr + txkop201.capc + txkop201.casf + txkop201.case

They work fine, but when I press on one record line, the value of free capacity is changing.
The first image are the normal values, the second image is when the record is clicked once, and the third image is when the record is clicked again.
When I click the refresh button on the session, the values go back as they were in the beginning.

Could it be logic problem or is it something else?

Thanks in advance

mark_h
19th September 2023, 15:59
Debug the session and run thru it step by step. My first thought is free capacity gets calculated before you know what the required.capa is. Since required.capa comes after free.capacity on the form. Debugging you can put breaks on those lines and see what might be up.

darkoGj
20th September 2023, 15:55
I debugged the fields, they seem to be working fine.
One thing that I have discovered about calculated fields is that their value is always changing whenever there is a change in the fields from which it is being calculated.

Since my calculated field: 'free.capacity' is being calculated from a table field and a calculated field 'required.capa' it will always change the value because my calculated field 'required.capa' is changing its value.
Tested the same thing and put the 'free.capacity' field in my required.capa field and when I selected a record in the session, required.capa was changing its value as well.

Do you happen to know any work around where a calculated field is being calculated from another calculated field, but to prevent value change?

mark_h
20th September 2023, 18:17
Nothing I can think of right off the top of my head. In 4c4 I did use sometimes use a variable for forms where - so like in the before program I would set it to one. As it went thru the form I would setup some fields if the value was 1. After the fields were displayed I would set this value to 2. So as long as they stayed on that record or form they value would stay at 2. But if they hit next record the value would go back to 1 and the fields would be re-setup for the new record. I know I did this at times, but can't think of a session with that type logic. And I do not recall doing this on like a mutli-occurance form - most of those forms I would just recalculate or look up the values again.

darkoGj
22nd September 2023, 12:43
I managed to fix this in a way that I put all of my logic into one before.display section and added some additional logic.

Thanks for your help, this is solved.