Hi folks,
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.
Code Snipped:
begin
item.SetFilter("Employee No.", eNumber."No.");
item.SetFilter("In Use", 'true');
check := item.FindFirst();
if check = false then begin
"Total Value" := 0;
eNumber.Modify(true);
exit(0);
end;
"Total Value" := 0;
summe := 0;
repeat
summe := summe + item."Value";
until item.next <= 0;
"Total Value" := summe;
eNumber.Modify(true);
end;
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! 
trigger OnAfterModify()
begin
SumUpValue();
end;
trigger OnAfterInsert()
begin
SumUpValue();
end;
trigger OnAfterDelete()
begin
SumUpValue();
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
1 Like
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?
Hi Thomas,
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.
1 Like