Create a list

Hi,   I am attempting to sync a list of items from another system using a web service. I create a list of item ID's in a non-persistable entity and I want to subtract my existing item ID's so I can iterate a loop over the item ID's that are not yet in mendix.  My existing item IDs are in an entity 'items' that cannot be subtracted from the list of item ID's because the list type is different.  I am trying to create a temporary list of item ID's from my Item entity, but I cannot seem to create a list from my entity. Can mendix create a list using values from another entity? (Iterate through each object and create a new list item for each object in the entity?) My work-around will be to sort the itemIDs and take the 'head' value subtracted by my head value of the existing items table, and iterate the loop by the difference. However, I feel that the subtraction of the lists would be a better way to accomplish.
2 answers


To create a new list, you'll need to perform a Create activity and then add the newly created Object to a list you've created.  However, this will be a list of objects with each object having an attribute which contains the ID value.  For this reason, I don't think comparing your 2 lists will give you the results you're after.  Mendix will compare the lists to see if the same objects are in both lists, not the same IDs.

I think the best way to accomplish this is to

  • retrieve the IDs you want to ensure are created in Mendix
  • create a list of the persistable entity
  • loop through the IDs you retrieved
  • for each iteration, use a retrieve action (with XPath) to see if the given ID is in your persistable entity
  • if it is not, create a new instance of the persistable entity with the current loop ID, without committing
  • add this newly created object to the list you created previously
  • after the loop is complete, commit your list

unless you have a very large number of IDs, this approach should work well.

Hope that helps,




Yes, that is what I was thinking.  I can't really evaluate if timing is accurate/good without a lot more information about your database.  However, .4 seconds per record for 22,000 means it would run for a bit less than 3 hours - this is definitely a good candidate for processing in a batch fashion.  I would approach as follows:

  • Create a new persistable entity to contain the records you retrieve from the webservices.  Include two attributes on this entity called Processed and Matched - both boolean
  • When you retrieve from the webservice, create records for each retrieved NPE in your new entity
  • Set up the microflow you have to retrieve items from your new persistable entity, and to only retrieve records where Processed = false() and a limit of 1,000
  • In your microflow, update each persistable entity object to indicate that it was processed and if it was matched or not (note: you can add other attributes to this entity to keep track of how it was matched, if a new object was created, or any other info you want to keep track of)
  • Set up this microflow to run in a scheduled event every 20 minutes or so (1000 records at .4 seconds should run in about 7 minutes, so give it about 3 times that to ensure you don't run into issues with overlapping transactions in the database)

If this is a one time exercise, you can remove the scheduled event once it completes successfully.

The reason I would take this approach is to avoid any out of resource errors you may see if you try to commit 22,000 objects in one commit action.


Iterate over your returned objects, within the iterator do a retrieve action that pulls back the "first" object based on the paramenter match [$iteratorobject/uniquevalue = uniquevalue], from there you have an exclusive split in that split you check to see if the retrieved object is empty, if so, create a new persisted object and set the values, if not, just continue the event.