I probably have something strange or I can’t see the mistake.
Maybe you know the Misc. Article Information - a related table to the employee - I have created a little extension to get a value of goods into it. Everything works fine but my last intention was to display the actual value of articles “In Use” to the employee card.
So when a article in the “Misc. Article Information” - table is modifyed, for example the boolean value “In Use” the new value is calculated - works as well with other changes.
Case: One last article is “In Use” = true and that one is changed to FALSE - the Record still gets the article as “In Use” = true and calculates it. And when it is changed again from false to true it doesn’t find it anymore - means the record.FindFirst() is FALSE.
item.SetFilter("Employee No.", eNumber."No.");
item.SetFilter("In Use", 'true');
check := item.FindFirst();
if check = false then begin
"Total Value" := 0;
"Total Value" := 0;
summe := 0;
summe := summe + item."Value";
until item.next <= 0;
"Total Value" := summe;
Ok, found the solution to it already.
My procedure was called with a OnAfterValidate trigger but the entry wasn’t modified at this point- so of course the filter could to it better.
I had to add my procedure to the “OnAfter…” - triggers
Everything works now!
Another Simple Solution could be to add a Flow Field on Employee Table that looks up the ‘Total Value’ filed on the Misc. Article Table with Filter for the Employee Code and InUse=True.
This will remove the need for your code altogether and users will be able to see this value being calculated at runtime automatically by the platform
Hehe I have already changed it to a FlowField and it works well when I open the employee card.
But I don’t know how to reload the flowfield after changes where made in the source tabel? It just reoads the flowfield when I close and open the employee card again.
Do you know a workaround?
Misc. Article is being changed from a different page. You will see the values on the employee card based on when it was opened.
I don’t see this as an issue in practical terms as you will not have many instances when someone is on the employee card and the Misc. Article is being changed all the time.
But if its an issue, you could use background tasks on the page to update the flowfield value.