How to count and aggregate parts used from tickets.
0
Hello, I am trying to develop a feature that counts engine parts used in the past 7 day period. I am able to successfully filter by date, but am struggling to create and then display a list in a microflow (see below). I have tried debugging, and have found that the parts are not being added to the aggregate part list. My understanding of the loop is that if the part does not currently exist in the aggregate part list, it will add that part and quantity to the list. If it does exist, it will create a new RepairPart object with an updated quantity, delete the previous RepairPart and then insert the new RepairPart object, preventing duplicate entries. Here is the relevant part of the domain model for context. Any help would be much appreciated :)
asked
Johnny Doestar
2 answers
0
A simpler way to make sure you don't have duplicates is simply doing a "Union" list action of the list on itself. This removes any duplicates without the need to loop over the list.
answered
Eline Bijkerk
0
Instead of creating new repairparts as orphans (the list will contain repairparts in tickets and created orphans), you could use OQL-entity to query a select count and group by, if you are using Mx10/11 or OQL-module in Mx9.
At least I would create the list based on a non-persistent entity and copy the relevant info from repairparts in it and update the quantity as found (not create).