{"id":12232,"date":"2023-07-18T12:56:31","date_gmt":"2023-07-18T17:56:31","guid":{"rendered":"https:\/\/www.mrc-productivity.com\/docs\/?post_type=ht_kb&#038;p=12232"},"modified":"2025-03-28T17:48:08","modified_gmt":"2025-03-28T22:48:08","slug":"messaging-and-scheduled-tasks-real-world-example","status":"publish","type":"ht_kb","link":"https:\/\/www.mrc-productivity.com\/docs\/knowledge-base\/messaging-and-scheduled-tasks-real-world-example","title":{"rendered":"Messaging and Scheduled Tasks &#8211; Real World Example"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Overview<\/h2>\n\n\n\n<p>The Messaging and Scheduled Task utility allows m-Power developers to call task groups on a scheduler or on-demand from their m-Power applications. This document will walk through a practical example of utilizing the Messaging and Scheduled Task utility to automate an email reminder. <\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">To use the Messaging and Scheduled Task utility to send emails, the appropriate mail server information must be initially configured within m-Power. Please see <a href=\"\/docs\/knowledge-base\/working-with-the-messaging-scheduled-tasks-plug-in#messaging-configuration\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a> for more information on this one-time configuration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example Scenario<\/h2>\n\n\n\n<p>Our customer (Betty), runs her fitness center Top Level Fitness where members pay a monthly fee to utilize the facilities. Every time a member submits a payment, Betty enters the date in a maintainer to keep track of when the last payment was received from that member. Every Sunday, Betty checks to see which members are behind on their monthly payments and sends them an&nbsp;email&nbsp;reminder of the late payment. Betty would like to automate the process, and have m-Power send the message for her to make the process more efficient and less time consuming.<\/p>\n\n\n\n<p>A Data List with Web Form maintainer is used by Betty to display each client&#8217;s information along with their last payment date. When a client submits a payment, Betty will update the &#8216;Last Paid&#8217; date appropriately:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/vue-images\/mst_example1.jpg\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Figure 1. A Data List with Web Form template built over client information<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Steps<\/h2>\n\n\n\n<p>Utilizing the m-Power Messaging &amp; Scheduled Tasks utility, we can create this solution for Betty in a few easy steps. This will involve the following:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Creating an Address Distribution List retrieval &#8211; \n<ul class=\"wp-block-list\">\n<li>This application will contain the email addresses of each recipient who will be emailed on a given Sunday.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Create a Single Row Data List retrieval.\n<ul class=\"wp-block-list\">\n<li>This application will serve as the message body of the email that is sent to the client.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Create the task group in the Messaging and Scheduled Task utility.\n<ul class=\"wp-block-list\">\n<li>The task group will reference the two above retrievals by simply defining which users (emails addresses) and which application will be sent to the client.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Add the task group to the scheduler to automatically fire every Sunday.<\/li>\n\n\n\n<li>Promote the applications and task logic to production<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1 &#8211; Address Distribution List<\/h3>\n\n\n\n<p>An Address Distribution List retrieval is built over the same table that is used in the maintainer application from Figure 1. This application uses the email field as the Dimension field and also has a calculation that uses date arithmetic to return the date one month ago.  <\/p>\n\n\n\n<p>A filter is added to the data model to only return records where the last paid date is less than or equal to the date exactly one month ago. When the Address Distribution List is ran, only two clients are returned based on that filter criteria:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/docs\/vue-images\/mst_example2.jpg\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Figure 2. Email of clients with late\/outstanding payments<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2 &#8211; Single Row Data List retrieval<\/h3>\n\n\n\n<p>Next, a retrieval will be made that will serve as the email body. This should be over the same table where the maintainer writes the last payment date. Using the m-Painter editor, the fields can all be removed from the form via the Page Options in the m-Painter toolbar and select <em>Replace with Original<\/em> (see image below).<\/p>\n\n\n\n<p>In the empty presentation, a table element and any desired free text may be added to craft the message. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/docs\/vue-images\/mst_example3.jpg\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Figure 3. A painted Retrieval application that will serve as the email body<\/figcaption><\/figure>\n\n\n\n<p>Use the the &#8220;Fields&#8221; option in the m-Painter toolbar was used to appropriately pull in the client information for a more personalized message. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/docs\/vue-images\/mst_example13.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Figure 4: Inserting fields into the email body<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3 &#8211; Create the Task Group and Task Message<\/h3>\n\n\n\n<p>Within the Messaging and Scheduled Tasks utility, a new Task Group will be created in order to send the retrieval from step 2, specifically it&#8217;s HTML content as the email body. <\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-alert\">For Step 3 only, please navigate to the <strong>Legacy <\/strong>Messaging and Scheduled Tasks in Legacy -> Admin -> Utilities -> Messaging and Scheduled Tasks. <br><br>After  Admin -> Messaging and Scheduled Tasks.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Within the task group, a single task message &#8220;Send a Regular Email&#8221; will be made, as shown below in Figure 5.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/docs\/images\/mst_example4_legacy.jpg\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Figure 5. Creating a task message in the Messaging and Scheduled Task utility<\/figcaption><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In the <strong>Target Application<\/strong> tab of the task message, the single row retrieval from Step 2 will be selected. No additional parameters are needed, and the output format will be HTML. \n<ul class=\"wp-block-list\">\n<li>The &#8220;Map Fields to Target Application&#8221; option may also be ignored.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>In the <strong>Recipients<\/strong> tab of the task message, the Address Distribution List retrieval from Step 1 will be selected. Under the &#8220;Retrieve List of Addresses from Database Table?&#8221; select the created distribution list retrieval.\n<ul class=\"wp-block-list\">\n<li>No additional parameters, email addresses, or field mappings are needed.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>In the <strong>Email Info<\/strong> tab, simply a subject line (e.g. Notice from your local gym) is entered.<\/li>\n\n\n\n<li>In the <strong>Review <\/strong>tab, review the task configuration and press Finish when done.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4 &#8211; Schedule the task group<\/h3>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-vertically-aligned-top is-layout-flow wp-block-column-is-layout-flow\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" src=\"\/docs\/vue-images\/mst_example5.jpg\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Figure 6. Scheduled Tasks option<\/figcaption><\/figure>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"has-text-align-left\">In general, m-Power task groups can be invoked one of three ways.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Manually from the Messaging &amp; Scheduled menu (for testing purposes)<\/li>\n\n\n\n<li>On-demand via an m-Power application<\/li>\n\n\n\n<li>Automated via the task scheduler<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-align-left\">In this situation, the task group must fire automatically every week, so the Scheduled Tasks option will be utilized, as shown highlighted in Figure 6.<\/p>\n<\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<p>After selecting Scheduled Tasks option, choose the &#8220;Add Scheduled Task&#8221; button. The following window as shown below in Figure 7. When creating the scheduled task, the task group from Step 3 is selected with the appropriate frequency for the task group to execute. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"\/docs\/vue-images\/mst_example6.jpg\" alt=\"\" style=\"width:668px;height:309px\"\/><figcaption class=\"wp-element-caption\">Figure 7. Creating a scheduled task for a task group<\/figcaption><\/figure>\n<\/div>\n\n\n<p>When selecting a frequency, the input box will be auto populated with the appropriate time, which is displayed in CRON time format. This input does not need to be manually edited, unless you have selected &#8216;Custom&#8217; for the frequency. <\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">If the selected frequency of a task group is &#8216;Custom&#8217;, there are many public websites such as this one <a rel=\"noreferrer noopener\" href=\"https:\/\/www.freeformatter.com\/cron-expression-generator-quartz.html\" target=\"_blank\">here<\/a> that can assist with describing the correct interval in CRON time format. <\/p>\n\n\n\n<p>Press &#8220;Save scheduled task&#8221; to return the Scheduled Tasks screen and the newly created task group will be shown. As will be indicated on the screen, changes to scheduled tasks do not take effect until the Tomcat service is restarted. For those with appropriate access, Tomcat may be reloaded from this screen. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5 &#8211; Promote to Production<\/h3>\n\n\n\n<p>The applications and the task information will need to be promoted to production. mrc <strong>always<\/strong> recommends to run all scheduled tasks out of production, rather than within a development environment. <\/p>\n\n\n\n<p>In Admin -&gt; Promote to Production a new project is made to organize all the files and applications that will be promoted. <\/p>\n\n\n\n<p>These items will need to be added to the project in order to then be promoted:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The Address Distribution List and the Single Row Data list retrievals<\/li>\n\n\n\n<li>mrc_distributions.txt (Task Groups)<\/li>\n\n\n\n<li>mrc_distributions_jobs_mrcdb_as400_remote1.txt (Scheduled Tasks)<\/li>\n\n\n\n<li>web.xml<\/li>\n<\/ul>\n\n\n\n<p>The file that enables the scheduler in production is the messaging.properties file. This file should NOT be re-promoted <\/p>\n\n\n\n<p>The web.xml and both task specific files are found in the Other Files tab:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/docs\/vue-images\/mst_example9.jpg\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Figure 8 &#8211; Selecting task files from the Other Files section<\/figcaption><\/figure>\n\n\n\n<p>Once found in the list, press the green Promote icon as show in Figure 8 to add to the promotion review. <\/p>\n\n\n\n<p>Any applications are added to the project via Project Options -&gt; Add apps to project dropdown, and once added will appear within the appropriate application tab (ex. Retrievals). These will also be added to the promotion review:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/docs\/vue-images\/mst_example10.jpg\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Figure 9 &#8211; Selecting two retrievals added to the project<\/figcaption><\/figure>\n\n\n\n<p>Select the Promotion Review button to finalize the promotion process. In the Review section, all the files\/application that are ready to promote will be listed. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/docs\/vue-images\/mst_example12.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>Press Next to proceed to the Promotion Locations and promote the files to production.  Make sure to restart production Tomcat once the files have been promoted.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview The Messaging and Scheduled Task utility allows m-Power developers to call task groups on a scheduler or on-demand from their m-Power applications. This document will walk through a practical example of utilizing the Messaging and Scheduled Task utility to automate an email reminder. Example Scenario Our customer (Betty), runs&#8230;<\/p>\n","protected":false},"author":2,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[304],"ht-kb-tag":[],"class_list":["post-12232","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-messaging"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/12232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/comments?post=12232"}],"version-history":[{"count":47,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/12232\/revisions"}],"predecessor-version":[{"id":14577,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/12232\/revisions\/14577"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/media?parent=12232"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-category?post=12232"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-tag?post=12232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}