Preventing Duplicates

Hello.  I am brand new to this platform and struggling with a few things so please bare with me on what may be obviously simple. Scenario: I have a MF that retrieves a list (emails from Exchange) into a non-persistable entity.  I originally wanted to then write conditionally these objects to a persistable table (condition is does not already exist via unique ID and has a matching value on a single attribute to another entity).  Anything with Commit or Create (in a loop) in the MF I could not figure out how to infer to write to the persistable table as it is not part of the MF.  Instead I changed the non-persistable entity to a persistable entity. Figured an association to the table with a potential matching value would handle one of the above requirements and adding a validation rule on an attribute for unique would handle the duplication issue (only want it to keep newly fetched emails, not ones that have already been stored) .  What occurs is the validation error is triggered and the entire commit is aborted.  Having a function that allows the keeping of uniquely retrieved objects I would think would be basic but for the life of me, cannot figure it out and thinking perhaps I am going about this entirely wrong.
4 answers

If you have the data in a list you in the MF then you can add a loop with the list as input parameter.

Before the loop create a list that holds the persitent objects that you will be creating in the loop. (this list is initially empty)

In the loop do a retrieve from the database of the persistent entity that has the same ID as the iterator object (and maybe other contraints). After this add an exclusive split checking if the persitent entity was retrieved (something like: $retrievedObjectedFromDB = empty) then if the obejct was not retrieved (on the true exit of the split) add a create object activity and create you new persitent object. With a change list action add the new object to the list created before the loop. On the false exit add a continue event.

After the loop add a commit object(s) action and pass the list to the action to write the data to the database.

Be aware that this descrioption of the microflow does not take into account that in the initial list of emails in the MF could contain duplicates. If this is the case then first create a new empty list, add a loop with the original list and then first check if the new list contains the iterator object, if not add the object else continu to the next object. Now you have a list of unique objects and you can use this in the way described above.

Hope this helps you in finding the solution


HI – would this solution work if the records are being imported through the Excel Importer widget or the Flat File Importer widget from the app store? It would seem I’d have to have the microflow execute AFTER the import is done and not as part of the import itself?


With the Excel importer there is no requirement to use non persistent entities.
So basically you can create a persistent datamodel and link them to corresponding excel importer template.


I’m trying to put in a control where, if the user imports a file twice, the entity won’t create duplicate records … Can a “unique constraint” be set on a set of columns in an entity?