{"id":1725,"date":"2023-09-25T10:22:33","date_gmt":"2023-09-25T02:22:33","guid":{"rendered":"https:\/\/five.co\/?p=1725"},"modified":"2024-03-20T11:33:43","modified_gmt":"2024-03-20T03:33:43","slug":"automating-processes-in-five-using-jobs","status":"publish","type":"post","link":"https:\/\/preview-php85.dzine.org\/five\/blog\/automating-processes-in-five-using-jobs\/","title":{"rendered":"Automating Processes In Five: Using Jobs"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"576\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Five.Co-Automating-Processes-In-Five-Using-Jobs-1-1024x576.png\" alt=\"Automating Processes In Five: Using Jobs\" class=\"wp-image-1740\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Five.Co-Automating-Processes-In-Five-Using-Jobs-1-1024x576.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Five.Co-Automating-Processes-In-Five-Using-Jobs-1-300x169.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Five.Co-Automating-Processes-In-Five-Using-Jobs-1-768x432.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Five.Co-Automating-Processes-In-Five-Using-Jobs-1.png 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Five Lab: Automating Processes In Five By Using Jobs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Welcome to Five Labs, a step-by-step guide to building applications using Five. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This lab will guide you through the process of creating Jobs in Five. Jobs in Five are utilized to <strong>automate functions<\/strong>, allowing you to <strong>schedule and execute them on a recurring basis<\/strong>. The objective of the tutorial is to:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Download and import the <a href=\"https:\/\/preview-php85.dzine.org\/five\/use-cases\/task-management-system\/\" data-type=\"URL\" data-id=\"https:\/\/preview-php85.dzine.org\/five\/use-cases\/task-management-system\/\">Task Management Template<\/a> in Five.<\/li>\n\n\n\n<li>Write and manage JavaScript functions.<\/li>\n\n\n\n<li>Adding a reminder feature in the Task Management Template.<\/li>\n\n\n\n<li>Creating Jobs in Five.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div style=\"background-color: #001524;\"><hr style=\"height: 5px;\" \/>\n<pre style=\"text-align: center; overflow: hidden; white-space: pre-line;\"><span style=\"color: #f1ebda; background-color: #4588d8; font-size: calc(18px + 0.390625vw);\"><strong>Sign Up For a Free Download<\/strong>\n<span style=\"font-size: 14pt;\">Download Five Today and Start Developing<\/span><\/span><\/pre>\n<p style=\"text-align: center;\"><a href=\"https:\/\/preview-php85.dzine.org\/five\/get-started\/\" target=\"_blank\" rel=\"noopener\"><button style=\"background-color: #f8b92b; border: none; color: black; padding: 20px; text-align: center; text-decoration: none; display: inline-block; font-size: 18px; cursor: pointer; margin: 4px 2px; border-radius: 5px;\"><strong>Free Sign Up<\/strong><\/button><br \/><\/a><\/p>\n<hr style=\"height: 5px;\" \/><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Lab Objectives<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By the end of this lab, you will have learned how to write Jobs in Five that can run your Actions in Five on a recurring basis. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Typical use cases for jobs are, for example, scheduling an email report on a weekly basis, checking for new orders daily, or notifying users of incoming requests every minute. Five&#8217;s Jobs feature lets us schedule functions at regular, time-based intervals.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To get started, here\u2019s what we need:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Have Five installed in your system or run Five on the cloud (with a paid subscription).<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\"><span style=\"color: #f1ebda; background-color: #4588d8; font-size: calc(12px + 0.390625vw);\"><strong>Don&#8217;t Feel Like Reading?<\/strong><\/span><\/mark>&nbsp;<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\">Watch the YouTube video and learn how to use jobs to schedule tasks in Five.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Using Use Cases Applications : Writing And Automating Functions In Five\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/E25v9v7iyFM?start=2&#038;feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Downloading And Importing The Task Management Template<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">First, let&#8217;s import a template into Five so we can get a headstart and after that, we can jump right into our functions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For this tutorial, we will be using the <a href=\"https:\/\/preview-php85.dzine.org\/five\/use-cases\/task-management-system\/\" data-type=\"URL\" data-id=\"https:\/\/preview-php85.dzine.org\/five\/use-cases\/task-management-system\/\">Task Management Template<\/a>, and we will be adding a Reminder feature to this app such that we get a notification whenever a task is due.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Download the template from the link above and import it into Five.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"548\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-26-1024x548.png\" alt=\"\" class=\"wp-image-1726\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-26-1024x548.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-26-300x160.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-26-768x411.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-26-1536x821.png 1536w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-26-2048x1095.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Click the &#8216;<strong>Manage<\/strong>&#8216; button to enter the development environment, then select &#8216;<strong>Database Modeler<\/strong>&#8216; from the &#8216;<strong>Data<\/strong>&#8216; menu to view the app&#8217;s database.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Task Management application is straightforward and consists of four database tables: tasks, reminders, task categories and categories.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It also features some pre-constructed forms, charts, and queries for your perusal. We will use the &#8216;Reminder&#8217; table to build a simple reminder feature for this app.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"548\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-27-1024x548.png\" alt=\"\" class=\"wp-image-1727\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-27-1024x548.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-27-300x160.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-27-768x411.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-27-1536x821.png 1536w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-27-2048x1095.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Defining JavaScript Functions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now that we have an understanding of our application, let&#8217;s jump into writing some code. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Inside Five, navigate to the \u2018<strong>Code Editor<\/strong>\u2019, which you can find inside &#8216;<strong>Logic<\/strong>&#8216;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click on the \u2018<strong>+<\/strong>\u2019 icon to initiate a new function. Assign it a meaningful name (we will call it sendReminder) and choose your preferred language, either TypeScript or JavaScript.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img width=\"1024\" height=\"548\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/image-2.png\" alt=\"\" class=\"wp-image-1728\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/image-2.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/image-2-300x161.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/image-2-768x411.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We will start by retrieving all the reminder dates from our table. We can do this by invoking a simple SQL statement through our function. <\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"function sendReminder(five, context, result) {\n  let sqlStatement = 'Select ReminderDate From Reminders'\n  let queryResults = five.executeQuery(sqlStatement, 0);\n  if (!queryResults.isOk()) {\n          five.createError(queryResults);\n  }\n   return five.success(result);\n}\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">function<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">sendReminder<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75; font-style: italic\">five<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75; font-style: italic\">context<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75; font-style: italic\">result<\/span><span style=\"color: #ABB2BF\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">  <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">sqlStatement<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #98C379\">&#39;Select ReminderDate From Reminders&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">  <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">queryResults<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">executeQuery<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">sqlStatement<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #D19A66\">0<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">  <\/span><span style=\"color: #C678DD\">if<\/span><span style=\"color: #ABB2BF\"> (<\/span><span style=\"color: #56B6C2\">!<\/span><span style=\"color: #E5C07B\">queryResults<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">isOk<\/span><span style=\"color: #ABB2BF\">()) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">          <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">createError<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">queryResults<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">  }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">   <\/span><span style=\"color: #C678DD\">return<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">success<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">result<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">We use <code>five.executeQuery()<\/code> and then we use<code>.isOk()<\/code> to check if the response resulted in any error. Since the response is a JSON object we can easily map through our results.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"function sendReminder(five, context, result) {\n  let sqlStatement = 'Select ReminderDate From Reminders'\n  let queryResults = five.executeQuery(sqlStatement, 0);\n  \n  if (!queryResults.isOk()) {\n          five.createError(queryResults);\n  }\n  \n  queryResults.values.map(item =&gt; {\n        five.log(&quot;Hello World&quot;)\n        let currentDate = Date.now();\n        let reminderDate = new Date(item.ReminderDate)\n        if(currentDate &gt;= reminderDate){\n            five.showMessage(&quot;You have a task due&quot;)\n        }\n  })\n   return five.success(result);\n}\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">function<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">sendReminder<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75; font-style: italic\">five<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75; font-style: italic\">context<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75; font-style: italic\">result<\/span><span style=\"color: #ABB2BF\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">  <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">sqlStatement<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #98C379\">&#39;Select ReminderDate From Reminders&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">  <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">queryResults<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">executeQuery<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">sqlStatement<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #D19A66\">0<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">  <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">  <\/span><span style=\"color: #C678DD\">if<\/span><span style=\"color: #ABB2BF\"> (<\/span><span style=\"color: #56B6C2\">!<\/span><span style=\"color: #E5C07B\">queryResults<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">isOk<\/span><span style=\"color: #ABB2BF\">()) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">          <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">createError<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">queryResults<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">  }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">  <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">  <\/span><span style=\"color: #E5C07B\">queryResults<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E5C07B\">values<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">map<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75; font-style: italic\">item<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">=&gt;<\/span><span style=\"color: #ABB2BF\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">log<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&quot;Hello World&quot;<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">currentDate<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">Date<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">now<\/span><span style=\"color: #ABB2BF\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">reminderDate<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">new<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">Date<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E5C07B\">item<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E06C75\">ReminderDate<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">if<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">currentDate<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">&gt;=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">reminderDate<\/span><span style=\"color: #ABB2BF\">){<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">            <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">showMessage<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&quot;You have a task due&quot;<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">  })<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">   <\/span><span style=\"color: #C678DD\">return<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">success<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">result<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">We simply iterate through each date and compare the set reminder date to the current date; if it&#8217;s due, we display a message using <code>five.showMessage()<\/code>. We have also used <code>five.log()<\/code> to test if the function is working or not when we call it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now that our function is somewhat prepared, let\u2019s test it first. We will start by attaching our function to a Test process. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Begin by navigating to Processes: click on \u2018<strong>Tasks<\/strong>\u2019, and then on \u2018<strong>Processes<\/strong>\u2019<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img width=\"1024\" height=\"190\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/image-3.png\" alt=\"\" class=\"wp-image-1729\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/image-3.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/image-3-300x56.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/image-3-768x143.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Create a new process by clicking on the yellow \u2018<strong>+<\/strong>\u2019 button and giving it a name (we will call it ReminderProcess). <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After that click on the \u2018<strong>Events<\/strong>\u2019 tab and since&nbsp;<a href=\"https:\/\/help.five.org\/2.1\/docs\/api\/Events\/introduction-to-fives-events\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Five supports event-driven programming<\/a>&nbsp;it will show you a list of events that the process goes through. We will attach our function to the \u2018<strong>Do Complete<\/strong>\u2019 event. Check out the screenshot below to see what this should look like inside Five. Save everything by clicking the tick mark. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"548\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-28-1-1024x548.png\" alt=\"\" class=\"wp-image-1730\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-28-1-1024x548.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-28-1-300x160.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-28-1-768x411.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-28-1-1536x821.png 1536w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-28-1-2048x1095.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Next, let\u2019s put our process into a menu so that we can access it in our end-user application. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Navigate to \u2018<strong>Visual<\/strong>\u2018 and then click on \u2018<strong>Menu<\/strong>\u2018, we will create a new menu item, and then in the \u2018<strong>Action<\/strong>\u2018 field we will select our process.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"548\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-29-1024x548.png\" alt=\"\" class=\"wp-image-1731\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-29-1024x548.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-29-300x160.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-29-768x411.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-29-1536x821.png 1536w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-29-2048x1095.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s run our application now. We will test our function in debug mode. This can be done by simply clicking on the \u25b6\ufe0f with the magnifying glass on the header.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img width=\"1024\" height=\"190\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/image-4.png\" alt=\"\" class=\"wp-image-1732\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/image-4.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/image-4-300x56.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/image-4-768x143.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Five will now run your application. But now you\u2019ll also have access to the inspector, which you will be able to find minimized on the right. Maximize it by clicking on the \ud83d\udd0e icon which will cause it to expand.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, select our <code>ReminderProcess<\/code> from the menus on the left, then click the check button in the top right to execute our process, which will trigger the \u2018<strong>Do Run<\/strong>\u2019 event.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"548\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-30-1024x548.png\" alt=\"\" class=\"wp-image-1733\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-30-1024x548.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-30-300x160.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-30-768x411.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-30-1536x821.png 1536w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-30-2048x1095.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When we run our process, we receive a message box, and the inspector also displays our logs, indicating our function is operating as intended.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s go back to our function and add the final changes. In order for jobs to work in Five our code should have a connection with our database.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"function sendReminder(five, context, result) {\n    const db = five.getDatabaseConnectionByID('TaskMageDB')\n\n    if (!db.isOk()) {\n\n        return five.createError(db, 'Connect to database failed');  \n\n    }\n\n    const tx = five.startTransaction(db);\n\n    if (!tx.isOk()) {\n\n        return five.createError(tx, 'Create transaction failed');  \n\n    }\n\n    let sqlStatement = 'Select ReminderDate From Reminders'\n    let queryResults = five.executeQuery(sqlStatement, 0);\n    \n    if (!queryResults.isOk()) {\n        five.createError(queryResults);\n    }\n\n    queryResults.values.map(item =&gt; {\n        five.log(&quot;It works&quot;);\n        let currentDate = Date.now();\n        let reminderDate = new Date(item.ReminderDate)\n        if(currentDate &gt;= reminderDate){\n            five.showMessage(&quot;You have a task due&quot;)\n        }\n    })\n    five.commit(tx)\n    return five.success(result);\n}\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">function<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">sendReminder<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75; font-style: italic\">five<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75; font-style: italic\">context<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75; font-style: italic\">result<\/span><span style=\"color: #ABB2BF\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">db<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">getDatabaseConnectionByID<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&#39;TaskMageDB&#39;<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">if<\/span><span style=\"color: #ABB2BF\"> (<\/span><span style=\"color: #56B6C2\">!<\/span><span style=\"color: #E5C07B\">db<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">isOk<\/span><span style=\"color: #ABB2BF\">()) {<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">return<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">createError<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">db<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;Connect to database failed&#39;<\/span><span style=\"color: #ABB2BF\">);  <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">tx<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">startTransaction<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">db<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">if<\/span><span style=\"color: #ABB2BF\"> (<\/span><span style=\"color: #56B6C2\">!<\/span><span style=\"color: #E5C07B\">tx<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">isOk<\/span><span style=\"color: #ABB2BF\">()) {<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">return<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">createError<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">tx<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;Create transaction failed&#39;<\/span><span style=\"color: #ABB2BF\">);  <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">sqlStatement<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #98C379\">&#39;Select ReminderDate From Reminders&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">queryResults<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">executeQuery<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">sqlStatement<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #D19A66\">0<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">if<\/span><span style=\"color: #ABB2BF\"> (<\/span><span style=\"color: #56B6C2\">!<\/span><span style=\"color: #E5C07B\">queryResults<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">isOk<\/span><span style=\"color: #ABB2BF\">()) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">createError<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">queryResults<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E5C07B\">queryResults<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E5C07B\">values<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">map<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75; font-style: italic\">item<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">=&gt;<\/span><span style=\"color: #ABB2BF\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">log<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&quot;It works&quot;<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">currentDate<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">Date<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">now<\/span><span style=\"color: #ABB2BF\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">reminderDate<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">new<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">Date<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E5C07B\">item<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E06C75\">ReminderDate<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">if<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">currentDate<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">&gt;=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">reminderDate<\/span><span style=\"color: #ABB2BF\">){<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">            <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">showMessage<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&quot;You have a task due&quot;<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    })<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">commit<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">tx<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">return<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">success<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">result<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">In the snippet above, we&#8217;ve appended several lines at the beginning of our existing function to establish a database connection. Initially, we utilize <code>five.getDatabaseConnectionByID()<\/code>, passing &#8216;TaskMageDB&#8217; as the argument, which is the name of our database<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To confirm the name of our database, we can click on the &#8216;<strong>Data<\/strong>&#8216; menu, followed by &#8216;<strong>Database<\/strong>&#8216;, which should display a list of all available databases.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After that, we simply start a transaction using <code>five.startTransaction()<\/code>. Finally, just before executing our return statement, we use <code>five.commit()<\/code>, passing in the transaction variable, to commit our modifications. (<strong>Note<\/strong>: these steps are only required when we are working with Jobs in Five )<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before proceeding, we will make one last change and that is replacing the <code>showMessage()<\/code> function with <code>sendNotification()<\/code>. Currently, we are showing a dialogue box containing our message which is not an ideal way of getting reminders so instead we will be using Five&#8217;s inbuild notifications. We simply replace five.showMessage() with this:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"five.sendNotification(&quot;You have a task due&quot;)\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">sendNotification<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&quot;You have a task due&quot;<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>sendNotification() <\/code>function is designed with multiple users in mind, and thus, it expects a user key to identify the recipient of the notifications. Since we plan to use this function to send notifications to ourselves, we will need our user key.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One method to retrieve our key is by calling the <code>five.currentUserKey()<\/code> method. To do this, simply invoke this method within the inspector of your browser. If you&#8217;re running the local version, access the inspector by selecting &#8216;<strong>File<\/strong>&#8216; on the top left, followed by &#8216;<strong>Debug<\/strong>&#8216; in your end-user application.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"572\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-31-1024x572.png\" alt=\"\" class=\"wp-image-1735\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-31-1024x572.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-31-300x167.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-31-768x429.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-31-1536x857.png 1536w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-31-2048x1143.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We will copy this key and paste it as an argument inside our code and now our function should look like this:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"function sendReminder(five, context, result) {\n    const db = five.getDatabaseConnectionByID('TaskMageDB')\n\n    if (!db.isOk()) {\n\n        return five.createError(db, 'Connect to database failed');  \n\n    }\n\n    const tx = five.startTransaction(db);\n\n    if (!tx.isOk()) {\n\n        return five.createError(tx, 'Create transaction failed');  \n\n    }\n\n    let sqlStatement = 'Select ReminderDate From Reminders'\n    let queryResults = five.executeQuery(sqlStatement, 0);\n    if (!queryResults.isOk()) {\n        five.createError(queryResults);\n    }\n\n    queryResults.values.map(item =&gt; {\n        let currentDate = Date.now();\n        let reminderDate = new Date(item.ReminderDate)\n        if(currentDate &gt;= reminderDate){\n            five.sendNotification(&quot;10000000-4444-4444-4444-000000000001&quot;,&quot;You have a task due&quot;)\n        }\n    })\n    five.commit(tx)\n    return five.success(result);\n}\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">function<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">sendReminder<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75; font-style: italic\">five<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75; font-style: italic\">context<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75; font-style: italic\">result<\/span><span style=\"color: #ABB2BF\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">db<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">getDatabaseConnectionByID<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&#39;TaskMageDB&#39;<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">if<\/span><span style=\"color: #ABB2BF\"> (<\/span><span style=\"color: #56B6C2\">!<\/span><span style=\"color: #E5C07B\">db<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">isOk<\/span><span style=\"color: #ABB2BF\">()) {<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">return<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">createError<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">db<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;Connect to database failed&#39;<\/span><span style=\"color: #ABB2BF\">);  <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">tx<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">startTransaction<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">db<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">if<\/span><span style=\"color: #ABB2BF\"> (<\/span><span style=\"color: #56B6C2\">!<\/span><span style=\"color: #E5C07B\">tx<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">isOk<\/span><span style=\"color: #ABB2BF\">()) {<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">return<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">createError<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">tx<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;Create transaction failed&#39;<\/span><span style=\"color: #ABB2BF\">);  <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">sqlStatement<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #98C379\">&#39;Select ReminderDate From Reminders&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">queryResults<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">executeQuery<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">sqlStatement<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #D19A66\">0<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">if<\/span><span style=\"color: #ABB2BF\"> (<\/span><span style=\"color: #56B6C2\">!<\/span><span style=\"color: #E5C07B\">queryResults<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">isOk<\/span><span style=\"color: #ABB2BF\">()) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">createError<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">queryResults<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E5C07B\">queryResults<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E5C07B\">values<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">map<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75; font-style: italic\">item<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">=&gt;<\/span><span style=\"color: #ABB2BF\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">currentDate<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">Date<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">now<\/span><span style=\"color: #ABB2BF\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">reminderDate<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">new<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">Date<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E5C07B\">item<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E06C75\">ReminderDate<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">if<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">currentDate<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">&gt;=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">reminderDate<\/span><span style=\"color: #ABB2BF\">){<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">            <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">sendNotification<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&quot;10000000-4444-4444-4444-000000000001&quot;<\/span><span style=\"color: #ABB2BF\">,<\/span><span style=\"color: #98C379\">&quot;You have a task due&quot;<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    })<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">commit<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">tx<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">return<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">success<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">result<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Scheduling Our Job<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s finally set up our Job to make sure the functions runs on a regular schedule.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Start by clicking on <strong>&#8216;Tasks&#8217;<\/strong> then &#8216;<strong>Jobs&#8217;<\/strong>. Similar to creating our <code>ReminderProcess<\/code>, create a new job by clicking on the yellow \u2018<strong>+<\/strong>\u2019 button and giving it a name. Inside the Action lookup select &#8216;ReminderProcess&#8217; or whatever name you assigned it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"548\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-21-1-1024x548.png\" alt=\"\" class=\"wp-image-1736\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-21-1-1024x548.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-21-1-300x160.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-21-1-768x411.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-21-1-1536x821.png 1536w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-21-1-2048x1095.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">For testing purposes, we are going to schedule our Job to execute every minute.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we run our application and after 1 minute we get an alert for our notifications in the \ud83d\udd14icon on the header bar.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"190\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-32-1-1024x190.png\" alt=\"\" class=\"wp-image-1737\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-32-1-1024x190.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-32-1-300x56.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-32-1-768x142.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-32-1-1536x285.png 1536w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-32-1-2048x380.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Clicking on the bell icon will open up our notifications. (<strong>Note<\/strong>: we receive 5 notifications as we have 5 tasks that are due from our Reminder Table).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"548\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-28-1024x548.png\" alt=\"\" class=\"wp-image-1738\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-28-1024x548.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-28-300x160.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-28-768x411.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-28-1536x821.png 1536w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Frame-28-2048x1095.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Congratulations! We have successfully built a simple reminder feature for our Task Management application.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this Five Lab, we&#8217;ve navigated through the process of automating functions using Jobs in Five. Jobs lets us schedule tasks, so that they run on a regular schedule, such as every minute, every day or every week.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We started by importing a Task Management Template to get a head start and then delved deeper into writing JavaScript functions, focusing on creating a reminder feature. We learned how to define, test, and refine our functions, ensuring they operate as intended, and how to connect them to our database, allowing for seamless interaction and data retrieval.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Moreover, we explored how to schedule our Jobs, allowing us to automate the execution of functions on a recurring basis, enhancing the efficiency and productivity of our application. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Five Lab: Automating Processes In Five By Using Jobs Welcome to Five Labs, a step-by-step guide to building applications using Five. This lab will guide you through the process of creating Jobs in Five. Jobs in Five are utilized to automate functions, allowing you to schedule and execute them on a recurring basis. The objective [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":1740,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_eb_attr":"","_uag_custom_page_level_css":"","footnotes":""},"categories":[21],"tags":[],"class_list":["post-1725","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"uagb_featured_image_src":{"full":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Five.Co-Automating-Processes-In-Five-Using-Jobs-1.png",1280,720,false],"thumbnail":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Five.Co-Automating-Processes-In-Five-Using-Jobs-1-150x150.png",150,150,true],"medium":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Five.Co-Automating-Processes-In-Five-Using-Jobs-1-300x169.png",300,169,true],"medium_large":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Five.Co-Automating-Processes-In-Five-Using-Jobs-1-768x432.png",768,432,true],"large":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Five.Co-Automating-Processes-In-Five-Using-Jobs-1-1024x576.png",1024,576,true],"1536x1536":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Five.Co-Automating-Processes-In-Five-Using-Jobs-1.png",1280,720,false],"2048x2048":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2023\/09\/Five.Co-Automating-Processes-In-Five-Using-Jobs-1.png",1280,720,false]},"uagb_author_info":{"display_name":"Pranoy Sarkar","author_link":"https:\/\/preview-php85.dzine.org\/five\/author\/f1v5_ed8_au\/"},"uagb_comment_info":0,"uagb_excerpt":"Five Lab: Automating Processes In Five By Using Jobs Welcome to Five Labs, a step-by-step guide to building applications using Five. This lab will guide you through the process of creating Jobs in Five. Jobs in Five are utilized to automate functions, allowing you to schedule and execute them on a recurring basis. The objective&hellip;","_links":{"self":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts\/1725","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/comments?post=1725"}],"version-history":[{"count":0,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts\/1725\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/media\/1740"}],"wp:attachment":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/media?parent=1725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/categories?post=1725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/tags?post=1725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}