in this video we will learn about workflow and task definition in Oracle Apex 23.2 version we will create a sample leave approval application to demonstrate how workflow works we will follow below steps and I will explain about each step in detail one in task definition create approval task two Define workflow three create workflow console page four create unified task list page five create leave application page six create leave approval page so let's begin first we will create a leave detail table where we will save leave detail now now create a workflow sample application now go to Shared component and in task definition create approval task type name of the task in subject we will use substitution variable as empore name which we will pass while initiating this task potential owner is the user to whom this task will be assigned add potential owner and participants value type can we static SQL query function body or expression here we will use static value as approver this is the user that we have already created now add the parameters ID and empore name _ name we are using in subject these param we will pass while initiating this task you can Define action also which will be performed when this task is completed for now we don't need this so we will not create any action task detail page number is the page number from where this task will be completed in our case it will be leave approval page that we will create later and will pass here now in shared component we will create a workflow where we will Define complete leave approval workflow give name of the workflow as leave request workflow give title as you have a leave request from empore name here empore name is a parameter name which we will pass while starting this workflow now create to parameters ID and empore name which we will pass when starting this workflow e in this workflow first activity will be leave application submitted which will be initiated by the user who apply for the leave second activity will be send email after user apply for a leave an email will be sent to the person who will approve this leave in from email I will keep a ppor email as default into email I will use my email ID because we have to check if email is sent or not in place of this we can also use workflow parameter as substitution and also we can use activity variable that we will learn later in this video you can use email template also if you have any if you if you don't have any email template you can write directly in subject and body you can use substitution variable also here like I am using empore name here now we will create activity variable for approver name for Value you can use static value item SQL query expression or function body for example if you want to get the name of the manager who will approve this leave you can write SQL query to return the value based on workflow parameter for the workflow you can pass employee ID of the employee who apply for the leave and based on that using SQL query or function body you can return manager name here I will use static value as approver now use this variable in place of name as substitution now create one activity as send push notification after employee apply for leave manager will be notified with push notification on mobile phone in two enter username of the manager again you can use parameter or activity variable as substitution we will create an activity variable here with static value as approver and we'll use as substitution in body you can type the message that approver will see in push notification now create one more activity as human task create this activity will be automatically initiated after push notification is sent and will stay pending at manager end for approval after selection you can see parameters are automatically shown that we have added while defining this task now pass values to these parameters we will pass workflow parameters to these parameters now we will add one more activity as switch switch is used to make decision for example in our case we have to send email to the user who have applied for email here we will check if leave is approved then we will send approv email and if leave is cancelled then we will send cancel email to the employee select type as true false check in condition we will use row returned now write a select statement from leave uncore detail table where leave approval status is approved if this query will return any row then it's true else it's false now create connection connection means a path to the next activity select the condition when workflow will choose this path we will select true on true we will add one more activity as send approval email to the employee who has applied for the leave in two we will use hardcoded email you can use workflow parameter or activity variable in place write the subject and body text if you don't have email template now create one activity variable for approval remarks if approver enter any remarks while leave approval we will get that remarks and will send an em email write a query to get remarks now use this variable in email body as substitution now we will follow same steps for cancel email we will create one connection for false condition and will add one activity as send email similar to approval e e now create one connection to each activity to direct the workflow to the end now verify that each activity have connection to the next activity it will give error if there is no connection to next activity except end of workflow pass workflow parameter ID as details primary key item now our workflow is ready in next step we will create Pages for leave application leave approval unified task and workflow console first we will create workflow console page workflow console page is like a dashboard where we will see all the workflows with status by default application ID is commented we will uncomment it because we want to see workflows of this application only now create one more page as unified task list unified task list is like inbox where you can see all tasks list which are pending with the user who is currently logged in create one more page for leave application as form on leave detail table similarly create one more page for leave approval as form on leave detail table this page will be a model dialogue now on leave application form we will hide fields which are not required to while applying for a leave set app user as default value for _ name field make leave type as select list with static values as casual and medical change label for create button and set success message now create one more process to start the workflow as this is the first activity of workflow select type as workflow now select type as start under settings and in definition select the workflow we recently created in details primary key item select primary key item the value of which will be returned by the above process now pass values to workflow parameters as page items on form now we will make some similar changes on leave approval page e e e now we will create one more process to Mark the task as complete that was initiated automatically by workflow after sending push notification select type as approve under settings create one page item as task ID which will contain unique autogenerated task ID we will pass value to this page item when this page is called from unified task page pass this page item to task ID item under setting based on this item system will identifi which task has to Mark as complete now create one computation under beforeand header in this computation we will get the value of ID parameter into primary key page item this ID parameter has the value that we have passed while starting the workflow we need its value because we have to fetch leave detail on form based on this ID e now use this page item and task definition because from unified task page we have to call this page you can see this link is automatically created and task ID is being passed to task ID page item of leave approval page now we are done with the changes now we will check how this workflow is working I have already created to users as approver and applicant for testing I have logged in as applicant user now I will apply for the leave we missed one change in workflow in participant we need to provide workflow owner who can see all the workflows on the workflow console page we will give static value as approver username this user will be able to see all workflows you can use other options also like SQL query to fetch workflow owners now apply for the leave again from applicant user Now log in with approver user to see leave request and approve it now on pending leaves for approval page you can see to leave our pending that we applied from applicant user this page is Unified task list page only approver user can see pending leaves here because in task definition we have specified this user as potential owner when we click on link leave detail are automatically fetched from leave detail table we will approve this leave and we'll enter some remarks you can see that task has gone from the list now open leave dashboard page this page is a workflow console page where you can see all the workflow with status here only approver can see data on this page because we have specified this user as potential owner and workflow when you click on link you will see all activities of the workflow you can see variable and parameter region by default you can customize this page according to your need now see if we have received any emails when leave is approved or applied yes we have received email we have typed wrong parameter name in workflow that's why we are not able to see correct user name here we will correct it you can see other detail with remarks in email body now let's correct this parameter name in workflow now for push notification we need to do some setting in application definition go to application definition select Progressive web app enable post notification turn on installable it means download button will appear in the browser when this application link is opened now select the credential and create new setting page new setting page is a page where user can enable push notification now you can see setting link is added here you can see push notification page can be opened from here and we can enable or disable push notification from here that's all in this video please subscribe for more videos like this if you feel it was helpful for you thank you