Simple List Operation - Exclude and Delete Non Associations

0
Hello - I'm trying to do a simple list operation. I have Students associated with Courses via Enrollment. I have a button that triggers a microflow, and I want to simply delete ALL non enrolled Students. I'm trying to A) pull a list of all students from the database, then B) pull a second list of all enrollments, then C) create a resulting list of Students that do not have an association in Enrollment, so that I can D) delete that list. For some reason, it's not working. I can't seem to compare (e.g. intersect) my Student and Enrollment lists. Any ideas? Thanks, Mark
asked
2 answers
1

Hi Mark,

Intersect would not work in this case. The two lists would need to be of the same type. What you can do is retrieve a list of all students without an association to a Enrollment using an xpath constraint. 

You would use retrieve from database and your constraint would look something along the lines of this.

[not(MyFirstModule.Student_Enrollment/MyFirstModule.Enrollment)]

This will return a list of all students that don't have an association to an enrollment.

 

Also here is some documentation on xpath.

https://docs.mendix.com/refguide/xpath

Hope this helps!

answered
0

In your example you would first need to create a list of enrolled students.

You could iterate over the enrollments, retrieve the enrolled students for each, then add those to a new list enrolled students. Then you have two lists with the same type of entity that you can operate on.

But if your data can all be accessed directly from database you can do that with a single XPATH retrieve as Austin suggests.

answered