Checking if object exists in database

3
Hi everyone, I'm working on an application for catering companies. The application has a inventory module where an employee can enter the desired stock for a certain product. To make the ordering process easier, I'm building a microflow that takes this desired amount and calculates how many times the product has to be ordered to meet the desired amount, and then present this in a list. However, I'm having trouble checking if the product is on the order list already or not. Every time execute the microflow, the same product is added to the database over and over again. The microflow currently looks like this (sorry it's a bit messy but I had to fit it in the screenshot): And my domain model is as follows: EDIT: Here's the microflow on Model Share: https://modelshare.mendix.com/models/ff060751-c83b-478a-bb2a-3bb1c950add9/microflow Any ideas? Thanks in advance!
asked
3 answers
3

I think it goes wrong at the Contains action. The Model Share lacks some functionality, so I can't see the actual check, but I'm assuming you're checking to see if the newly created referenceOrderItem is present in the list. Since contains checks object ID's this will always be false (your newly created referenceOrderItem is not present in the list).

answered
0

In the microflow, add an entity to retrieve object based on order ID and next add exclusive split to check if the retrieved object exists or not. Simple :)

answered
0

It is better to iterate the list and check the attribute with empty value in place of using contains action

answered