- Issue created by @ddt trung
- 🇩🇪Germany jurgenhaas Gottmadingen
I'm not an expert in the flags module, so I don't know the data model in detail. But I would imagine it should be possible to create a view that returns the list of users that flagged a specific entity. If you take the user list from that view, you can loop over that list and send individual emails to each of them. Examples of loops can be found in the library of the ECA Guide.
- 🇻🇳Vietnam ddt trung Vietnam
Hi Jurgenhaas,
Thank you so much for your quick and helpful response!
Your suggested approach – creating a View to return the list of users who flagged the entity, and then using ECA to loop over that list and send emails – makes perfect sense, and it's indeed the path we were trying to follow based on our understanding.
We were partially successful: We managed to create a Drupal View (using Relationships: Content -> Flagging -> User, and a Contextual Filter for the Content ID) that correctly outputs the list of users (or just their email addresses) who have the 'bookmark' flag on a given node. Testing the View directly with a node ID confirms it returns the expected users/emails.
However, we are stuck on the next step within the ECA UI. When we try to add an action after the event (Update content entity) or after fetching the flaggings (using Flag: get flagging for entity which is available) or executing the view (using Views: Execute query, as Execute View display seems unavailable), we cannot find any action named "Loop", "Iterate", "For Each" or similar in the list of available actions. This prevents us from processing the list of flaggings or users to send individual emails.
We have the following core ECA modules enabled on Drupal 11 (latest versions): eca_core, eca_ui, eca_content, eca_user, eca_flag, and eca_base. I did look at the loop examples in the ECA Guide you mentioned, but the fundamental problem is that the "Loop" action itself doesn't appear in the ECA model builder UI for us to select and configure.
Is the looping capability perhaps provided by a different ECA sub-module that we might be missing? Or is there another technique within ECA (using the available actions) to iterate over a list variable (like the result from Flag: get flagging for entity or Views: Execute query) and perform an action (like 'Send email') for each item? Or could this be a limitation/issue with the current ECA version for Drupal 11?
Our goal remains to send an individual notification email to each user who bookmarked the content when it's updated.
Thanks again for any further insights you might have! - 🇩🇪Germany jurgenhaas Gottmadingen
You need the eca_views submodule to receive the list of users from your view.
Then, building a loop is a sequence of actions and conditions, there is not just a "loop-action". A sample on how to build a loop can be found in this sample: Multi value field loop
- 🇻🇳Vietnam ddt trung Vietnam
Hi Jurgenhaas,
Thank you very much again for clarifying! It's very helpful to know that a loop is built as a sequence of actions and conditions, rather than a single specific action. Thanks also for the link to the 'Multi value field loop' example – I will study it closely.
I can confirm that I do have the eca_views submodule enabled, as well as eca_core, eca_ui, eca_content, eca_user, and eca_flag.
One constraint I have is that, as a screen reader user, I need to use the simpler, form-based ECA modeller (the "Classic Modeller" provided by eca_ui, I believe) because I'm unsure about the accessibility of the visual BPMN.io modeller (eca_bpmnio is currently disabled on my setup).
Looking at the available Actions within this form-based UI (the ones I listed previously), I see list actions like List: add item, List: compare items, List: count items, List: delete data, List: remove item, and List: save data. However, I don't readily see actions like "Get item at index", "Shift item" (get and remove first), "Pop item", nor explicit "Gateway" elements that might be used in the BPMN examples like the one you linked.
Could you perhaps elaborate on how the sequence described in the 'Multi value field loop' example might be constructed using the actions typically available in the simpler eca_ui modeller? Specifically, after fetching the list of flaggings (or the list of emails/users via the View approach), what sequence of these available actions and conditions would allow me to reliably process one item from the list per iteration, get the necessary data (like the user's email), perform the 'Send email' action, and then proceed to the next item until the list is empty?
My goal remains to send an individual email to each user who has the 'bookmark' flag when the relevant content is updated.
Thank you again for your guidance and patience!
Best regards - 🇩🇪Germany jurgenhaas Gottmadingen
It's the "List: Remove Item" action which lets you take one item (first or last) from the list into a token of their own. You can then do stuff with that item and go back to continue with this until there's no item left in the list.
- 🇻🇳Vietnam ddt trung Vietnam
Hi Jurgenhaas,
Thank you again for the key pointer about using the List: Remove Item action to simulate a loop! This is very helpful as the explicit 'Loop' action doesn't seem available in my UI.
Following up on my previous constraint: I am using the form-based ECA Classic Modeller (from eca_ui) due to screen reader accessibility needs, not the graphical BPMN modeller.
Could you possibly elaborate slightly on the specific sequence of Conditions and Actions needed to correctly implement the loop using List: Remove Item within this non-visual, list-based modeller?
Specifically, after fetching the list (let's call it bookmark_flaggings) and having the condition Compare number of list items (bookmark_flaggings > 0), the sequence would presumably be:
1. Condition: Compare number of list items (Is list > 0?) -> If TRUE, proceed...
2. Action: List: Remove Item (Input: bookmark_flaggings, Output: current_flagging)
3. Action: Load User entity based on current_flagging into flagger_user
4. Action: Send Email using flagger_user data.
5. ??? How to loop back? How do I configure the successor for the "Send Email" action (Step 4) to go back and re-evaluate the Condition in Step 1 within the ECA Classic/UI modeller? Is there a specific way to connect it back, or does the modeller handle the transition back to the condition automatically after the actions attached to its TRUE path complete?
Understanding how to structure this "go back to condition check" step within the form-based UI using List: Remove Item is the main piece I'm missing.
Thank you immensely for your help! - 🇩🇪Germany jurgenhaas Gottmadingen
This is a question for the classic modeller, I don't know if and how this works there. I would suspect that you want to declare the "Remove item" action as a successor to the send email action with the same condition.
May I ask you if your questions are coming from an LLM, e.g. ChatGPT? If that's the case, it were appropriate to disclose it, i.e. why and how AI has been used.
- 🇻🇳Vietnam ddt trung Vietnam
Hello jurgenhaas, Thank you for your response.
No, I don't use AI to compose replies etc.
I will try to carefully research the instructions from the official ECA website to find a solution.
Thank you for your patience.