Introduction
This is a process tool plugin to allow one to iterate through records/assignments to execute process tool plugin. When iterating through individual record/assignment, the target process tool will be set to record/assigment context. This enables the use of hash variables under the correct context.
There are 2 plugins in this bundle to cater to different use cases.
- Iterator Process Tool (Record)
Iterator Process Tool (Assignment)
If the records loaded are activity instances, please use the latter.
A plugin named "Database Query Process Tool" is also bundled together as utility for loading records.
Configurations
Load Records
Name | Description |
---|---|
Iterator Method |
|
List |
|
Iterator Process Tool |
|
Record ID | Specify which column to be used as record ID / primary key from the dataset. |
Execute Process Tool
Name | Description |
---|---|
Process Tool |
|
Advanced
Name | Description |
---|---|
Debug Mode | Turn this mode on to print out debugging information to the server log. |
Delay Between Execution |
|
Download Plugin
Please visit https://github.com/jogetoss/iterator-process-tool/releases to download the plugin.
Examples
Send Daily Reminder on Upcoming Meeting within 2 days
- In this example, we are making use of Scheduler plugin to trigger the plugin at 7am daily. Set the plugin to "Iterator Process Tool (Record)".
We can make use of "Database Query Process Tool" as the mean to pick up the records later. First, we will need to prepare the SQL to pick up bookings that are happening within 2 days from the time the job runs.
SELECT id, c_subject, c_name, c_room, c_date_from, c_date_from FROM app_fd_mrb_booking WHERE c_date_from > NOW() AND DATE(c_date_from) < DATE_ADD(NOW(), INTERVAL 2 DAY) /*pick up bookings happening within 2 days from now to send reminder*/
Take note that it is important that we return the "id" column as it will be used to set the record context for hash variable to work.- This is the complete configurations.
- Choose "Process Tool", followed by "Database Query Process Tool"
- Set "id" in "Record ID" for the reason explained above.
- In "Execute Process Tool", choose "Email Tool".
- The email tool will be triggered once per record it iterates through.
Observe the server log or check emails to verify.
INFO 15 Mar 2022 18:19:00 org.joget.marketplace.IteratorProcessToolRecord - Executing Iterator INFO 15 Mar 2022 18:19:00 org.joget.marketplace.DatabaseQueryProcessTool - Query: SELECT id, c_subject, c_name, c_room, c_date_from, c_date_from FROM app_fd_mrb_booking _WHERE c_date_from > NOW() AND DATE(c_date_from) < DATE_ADD(NOW(), INTERVAL 2 DAY)_/*pick up bookings happening within 2 days from now to send reminder*/ INFO 15 Mar 2022 18:19:00 org.joget.marketplace.DatabaseQueryProcessTool - Rows returned: [{c_subject=Product Discussion, c_room=44cefb42-289f-46db-b90c-6430224e8506, c_date_from=2022-03-16 09:00, c_name=Hugo, id=2960b356-161d-451a-8c2d-85fdebf2e111}, {c_subject=Project Debrief, c_room=44cefb42-289f-46db-b90c-6430224e8506, c_date_from=2022-03-17 09:00, c_name=Alexa, id=2960b356-161d-451a-8c2d-85fdebf2e121}] INFO 15 Mar 2022 18:19:00 org.joget.marketplace.IteratorProcessToolRecord - Iterator returned: 2 items: [{c_subject=Product Discussion, c_room=44cefb42-289f-46db-b90c-6430224e8506, c_date_from=2022-03-16 09:00, c_name=Hugo, id=2960b356-161d-451a-8c2d-85fdebf2e111}, {c_subject=Project Debrief, c_room=44cefb42-289f-46db-b90c-6430224e8506, c_date_from=2022-03-17 09:00, c_name=Alexa, id=2960b356-161d-451a-8c2d-85fdebf2e121}] INFO 15 Mar 2022 18:19:00 org.joget.marketplace.IteratorProcessToolRecord - Iterating item: 1 - Record: 2960b356-161d-451a-8c2d-85fdebf2e111 INFO 15 Mar 2022 18:19:00 org.joget.marketplace.IteratorProcessToolRecord$1 - Executing tool: executeProcessTool - org.joget.apps.app.lib.EmailTool INFO 15 Mar 2022 18:19:00 org.joget.marketplace.IteratorProcessToolRecord$1 - Executed tool: executeProcessTool - org.joget.apps.app.lib.EmailTool INFO 15 Mar 2022 18:19:00 org.joget.apps.app.lib.EmailTool - EmailTool: Sending email from=hugolim@outlook.com, to=hugo@joget.org, cc=, bcc=, subject=Booking Product Discussion INFO 15 Mar 2022 18:19:02 org.joget.apps.app.lib.EmailTool - EmailTool: Sending email completed for subject=Booking Product Discussion INFO 15 Mar 2022 18:19:05 org.joget.marketplace.IteratorProcessToolRecord - Finished item 1 - Record: 2960b356-161d-451a-8c2d-85fdebf2e111 INFO 15 Mar 2022 18:19:05 org.joget.marketplace.IteratorProcessToolRecord - Iterating item: 2 - Record: 2960b356-161d-451a-8c2d-85fdebf2e121 INFO 15 Mar 2022 18:19:05 org.joget.marketplace.IteratorProcessToolRecord$1 - Executing tool: executeProcessTool - org.joget.apps.app.lib.EmailTool INFO 15 Mar 2022 18:19:05 org.joget.marketplace.IteratorProcessToolRecord$1 - Executed tool: executeProcessTool - org.joget.apps.app.lib.EmailTool INFO 15 Mar 2022 18:19:05 org.joget.apps.app.lib.EmailTool - EmailTool: Sending email from=hugolim@outlook.com, to=hugo@joget.org, cc=, bcc=, subject=Booking Project Debrief INFO 15 Mar 2022 18:19:06 org.joget.apps.app.lib.EmailTool - EmailTool: Sending email completed for subject=Booking Project Debrief INFO 15 Mar 2022 18:19:10 org.joget.marketplace.IteratorProcessToolRecord - Finished item 2 - Record: 2960b356-161d-451a-8c2d-85fdebf2e121
- Once verified working, it is advisable to turn off the debug mode.