|
5 registered users in last 24 hours Workflow Developer's GuideThis document deals with how to use the services of the workflow package in your own package. For Deciders:
What Do I Gain?Given the formal specification of a workflow, the workflow package will keep track of what tasks are to be performed, notify via email the people that should perform them, and make sure that the same task doesn't accidentally get executed twice by different people.It'll also provide your users with a unified user-interface to help them keep track the tasks they are supposed to perform. This user-interface also acts as the single place to go for information relating to the task, such as inputs and aids in performing the specific task, a log of all prior activity on the case including comments, and a visual overview over the case. It also provides you with an interface for analyzing the performance of your workflow. You'll be able to spot bottlenecks, find overdue tasks, etc. Finally, as the package evolves based on input from you and other users, the features above will grow stronger, and more will be added. What Does It Take?The workflow process is centered around an object. In an insurance company, that could be an insurance claim; if you're writing the ticket-tracker, it would be the ticket itself; etc. So you need to define that object first, creating tables, etc., as necessary.From there on, there are four steps involved in taking advantage of the services of the workflow package in your application.
Defining Your ProcessThis is pretty simple. You simply use the web-based user-interface i.e., any combination of the Simple Process Wizard and the Advanced Process Builder, to define your process.When you're happy with your process and have tested it, you click on export process from the process page, to export the process to a SQL script file, which you can include in your distribution. But don't do this just yet. Make sure you've completed all of the steps below before you export it. Customize the User-InterfaceThe information provided by default on the task page is somewhat shallow. You will want to supply your own sub-templates to this page to display information specific to your object of concern. While defining your process, you can define the panels for each of the tasks. The panels consist of a header and the URL of the subtemplate you want to provide the contents of the panel. The URL is, due to the way the templating system works, not a real URL. Rather, it's a path to the file to include, and will typically look like this: Add a Mechanism for Starting CasesIf there must be a process for each and every object that your application is dealing with (claim reports, articles, tickets, etc.), then the smartest way of implementing this is to start a process case from the same API call that creates a new object of your type, like this:create or replace package body ticket
is
function new (
...
) return integer
is
v_ticket_id number;
v_case_id number;
begin
/* Create the ticket object */
v_ticket_id := ... ;
v_case_id := workflow_case.new(
workflow_key => 'ticket_wf',
object_id => v_ticket_id,
...
);
workflow_case.start_case(
case_id => v_case_id,
...
);
return v_ticket_id;
end;
...
end ticket;
You can also do this from an after insert trigger on the table holding your objects.
If, however, only some of your objects give rise to a process case, then you're better off creating a UI page for starting a case. The workflow API calls to use are the same as in the above. Integrate the User ExperienceThis basically consists of providing links from the relevant pages of your application to the relevant pages within the workflow package. It's reasonably safe to assume that the workflow package is mounted at/workflow/. If you want to be super-general, you'll have to query the sitemap tables for the correct URL stub.
The task page, specifically, takes a What are Callbacks?Callbacks are a mechanism for the Workflow Engine to execute code that you supply. You specify to the workflow engine the name of the PL/SQL function or procedure you want invoked, and the Workflow Engine invokes it with a pre-specified argument list. In other words, the procedure or function must have exactly the signature specified by the Workflow Engine, but apart from that, it can do anything.The principle for callback arguments is that it takes the minimum list of arguments necessary to fully qualify what transition or arc triggered it, plus a custom argument, the value of which is specified during the process design. The custom argument is there, so you can parameterize your callback. Say you have a callback that returns the a date one week from now. If you need another callback returning the date two weeks from now, you don't have to write a new PL/SQL function. You can supply one that takes the number of days as its custom arg, and returns the date custom arg days from now. The signatures are specified in Appendix A. Adding Guard CallbacksI assume you know what a guard is and what it does; otherwise, read the Conceptual Guide now. There is one special guard, default, denoted by a hash (#) symbol, which evaluated to true when all non-default guards evaluate to false. This is useful, because you normally want to make sure that exactly one of the guards on arcs going out of the same transition evaluate to true. It corresponds to the 'else' clause in an if-statement, or the 'default' clause in a switch statement. Apart from this, there is one guard callback function included in the pacakge, namely A guard callback must follow the signature given in appendix A, and return either Adding ActionIf you want an automatic transition, or any other transition, for that matter, to have side-effects of any kind, you can specify an action to be called either when the transition is enabled or when it fires.An action is also a callback, following the signature given for enable or fire callbacks below. Actions don't by themselves alter the state of the process, they only have side-effects. They can, however, set workflow attributes, which can then be queried by guards. You can use this to implement a process that doesn't require human intervention. If you have a process, such as billing a credit card, where a number of operations must happen in some non-trivial order, you can model the order and the dependencies in a workflow process, and have the actions performed automatically. By doing it this way, you separate the logic governing the overall process from the technicalities of actually performing the actions. Other CallbacksThere are a number of places where you can supply a callback to control the operation of the workflow engine in minute detail. These are:
Message TransitionsMessage transitions are used when the something outside of the workflow system triggers the transition e.g., the arrival of an email. What you'll need to do is write the code necessary to receive that email, and the call theworkflow_case.fire_message_transition API procedure to trigger the transition.
You're Ready To Go!This concludes our tutorial on everything you need to know to harness the powers of the workflow package in your own applications. Good luck.Appendix A. Callback Signatures
ReferencesRelated Workflow Topics
Related Object Types
Related Packages
|
