2 3 Peters

download 2 3 Peters

of 38

Transcript of 2 3 Peters

  • 7/27/2019 2 3 Peters

    1/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.4

    John Peters, JRPJR, Inc. 1

    Oracle Workflow Notifications

    John Peters

    JRPJR, [email protected]

  • 7/27/2019 2 3 Peters

    2/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.4

    John Peters, JRPJR, Inc. 2

    How many of you have worked with OracleWorkflow?

    How many of you have modified WorkflowNotifications?

    How many of you have a minimalunderstanding of PL/SQL

  • 7/27/2019 2 3 Peters

    3/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.4

    John Peters, JRPJR, Inc. 3

    How does Oracle Workflow build a

    Notification

    Some tips for setting up the WorkflowNotification mailer

    Some simple customizations you can

    perform on Workflow Notifications

    What you should learn from this presentation:

  • 7/27/2019 2 3 Peters

    4/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.4

    John Peters, JRPJR, Inc. 4

    All of my examples are Workflow 2.6.3

    This is the version shipped with 11.5.9

    Versions Being Shown

  • 7/27/2019 2 3 Peters

    5/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3

    John Peters, JRPJR, Inc. 5

    Primary emphasis of this presentation will

    be the changes to workflow notifications

    that are necessary for them to be sent

    outside of a company.

    The topics covered will be applicable even

    within a company if you want to personalize

    the notification messaging

    Presentation Emphasis

  • 7/27/2019 2 3 Peters

    6/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3

    John Peters, JRPJR, Inc. 6

    Notifications are comprised of:

    - A Notification Activity

    - A Message

    - A Message Template

    - Optional Message Item Attribute(s)

    Notification Components

  • 7/27/2019 2 3 Peters

    7/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3

    John Peters, JRPJR, Inc. 7

    Notification Activity Think of this as a container to hold and call the message from.

    This is what you will place on your workflow diagram.

    When inserting a Notification Activity on a workflow diagram

    remember to provide a value for the Performer. If you dont you

    will get a workflow runtime error about a NULL Performer.

  • 7/27/2019 2 3 Peters

    8/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3

    John Peters, JRPJR, Inc. 8

    Notification Expand Roles If you are sending the Notification to a Role (everyone with the System

    Administrator Responsibility) the Expand Roles is very important

    Checked, this will create a separate Notification to each person in the Role.

    If an action is expected every person has an opportunity to act on the

    Notification

    Unchecked, this will create a single Notification which is emailled to each

    person in the Role. The first person to act on the notification completes (orcloses) it.

  • 7/27/2019 2 3 Peters

    9/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3

    John Peters, JRPJR, Inc. 9

    Message

    This is what contains the text you are going to send.

    You can format messages at Text or HTML

    Message Bodies can include Attributes (variables)

  • 7/27/2019 2 3 Peters

    10/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3

    John Peters, JRPJR, Inc. 10

    Resulting Message This is the result of the HTML message body

    Notice the extra line Oracle Workflow Notification

    (FYI). This came from the message template.

  • 7/27/2019 2 3 Peters

    11/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3

    John Peters, JRPJR, Inc. 11

    Message Templates

    Oracle comes seeded with

    Message Templates in the

    System: Mailer Item Type.

    In the PC Client

    Workflow Builder Open the System: Mailer

    Item Type from the

    database

    The Internal Name is

    WFMAIL

  • 7/27/2019 2 3 Peters

    12/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3

    John Peters, JRPJR, Inc. 12

    Open FYI Mail Template

    Here is where that extra text comes from.

  • 7/27/2019 2 3 Peters

    13/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3

    John Peters, JRPJR, Inc. 13

    You Can Customize Templates

    Do not modify the Oracle Supplied Message Templates

    You can create custom Message Templates in theSystem: Mailer Item Type

    You can also create custom Message Templates in anyItem Type, including the one you are customizing.

    Details are in:Oracle Workflow Administrators Guide,

    RELEASE 2.6.3, Part No. B1028301

  • 7/27/2019 2 3 Peters

    14/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3

    John Peters, JRPJR, Inc. 14

    My Customized Template

  • 7/27/2019 2 3 Peters

    15/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3

    John Peters, JRPJR, Inc. 15

    How to Reference Customized Templates

    Workflow Mailer Configuration using OAM

  • 7/27/2019 2 3 Peters

    16/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 16

    How to Reference Customized Templates

    Workflow Message

    Attributes

    Right mouse button on the

    Message Name

    Select New Attribute

    This Attribute must have an

    internal name of

    #WFM_OPEN_MAIL_FYI

  • 7/27/2019 2 3 Peters

    17/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 17

    How to Reference Customized Templates

    The value must be of the format:

    :

  • 7/27/2019 2 3 Peters

    18/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 18

    Here is the result

    Notice other possibly objectionable messagecomponents if the message is going external

  • 7/27/2019 2 3 Peters

    19/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 19

    Message Attachments

    Message Attachments arecontrolled by the User

    Preferences

    To suppress the

    Attachments choose HTML

    mail

    This can be done at the User

    level

  • 7/27/2019 2 3 Peters

    20/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 20

    Message Attributes

    Message Attributes allow you to modify featuresof a Workflow Notification, without having to

    create separate Workflow Mailers.

    There are dozens of Special Message Attributes. I

    am only showing two here.

    #WFM_FROMChanges the From Email address

    #WFM_REPLYTOChanges the Reply To Email

    See the following document for more informationon Message Attributes:Oracle Workflow Developers Guide, Release 2.6.3

    Part No. B1028401

  • 7/27/2019 2 3 Peters

    21/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 21

    Using #WFM_FROM

    This message attribute will change the From EmailAddress in the Notification.

  • 7/27/2019 2 3 Peters

    22/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 22

    Document Message Attributes

    Document Attributes allow you to build a

    Message Body From a Query

    Document Type Attributes reference PL/SQL

    procedures to build a text stream Datatypes supported are:

    VARCHAR232KB Size Limitation

    CLOB4GB(possible limitations due to workflow engine limitation)

    BLOB4GB(possible limitations due to workflow engine limitation)

  • 7/27/2019 2 3 Peters

    23/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 23

    Create a Document Attribute This will be a holder for a reference to the PL/SQL

    procedure and any required parameters

    Right mouse on Attributes

    Select New Attribute

  • 7/27/2019 2 3 Peters

    24/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 24

    Create a Function This Workflow function will set the Document Attribute

    values when the Workflow is run. Right mouse on Function

    Select New Function

  • 7/27/2019 2 3 Peters

    25/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 25

    Create Workflow Process I am going to build a new demo Workflow Process

    Right mouse on Process

    Select New Process

  • 7/27/2019 2 3 Peters

    26/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 26

    Build the Workflow Process Drag Functions in to Process

    Set Document Attribute, then Send Notification

  • 7/27/2019 2 3 Peters

    27/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 27

    PL/SQL Code

    I have removed exception handling and other

    constructs to make the code easy to read.

    The first procedure sets the Document Attribute

    The second procedure builds the Document text

    stream.

  • 7/27/2019 2 3 Peters

    28/38

    07/19/04 NorCal OAUG TrainingDay, Paper 2.3 John Peters, JRPJR, Inc. 28

    Procedure to Set the Document Attribute

    Document Attributes Valuesplsql:/

    procedure = PL/SQL Procedure document_identifier = usually a concatenation ofITEM_TYPE:ITEM_KEY

    This is the only way to pass parameters specificto the Workflow Instance.

  • 7/27/2019 2 3 Peters

    29/38

    07/19/04 NorCal OAUG Training

    Day, Paper 2.3

    John Peters, JRPJR, Inc. 29

    PL/SQL CodeSet Attribute-- Portion of the Package ZZZZ_DEMO_WF_NOTIFICATIONS

    PROCEDURE SET_NOTIF_ATTRIBUTES (p_itemtype in varchar2,p_itemkey in varchar2,

    p_actid in number,

    p_funcmode in varchar2,

    p_resultout out varchar2)

    IS

    BEGINwf_engine.SetItemAttrText(p_itemtype,

    p_itemkey,

    'EMP_TABLE',

    PLSQL:ZZZZ_DEMO_WF_NOTIFICATIONS.EMP_TABLE/

    || p_itemtype || '| ||

    p_itemkey);

    END SET_NOTIF_ATTRIBUTES;

  • 7/27/2019 2 3 Peters

    30/38

    07/19/04 NorCal OAUG Training

    Day, Paper 2.3

    John Peters, JRPJR, Inc. 30

    PL/SQL CodeBuild Document (1)-- Portion of the Package ZZZZ_DEMO_WF_NOTIFICATIONS

    -- Procedure Call and Misc. Setup

    PROCEDURE EMP_TABLE (p_document_id in varchar2,

    p_display_type in varchar2,

    p_document in out varchar2,

    p_document_type in out varchar2)

    IS

    v_itemtype varchar2(200);v_itemkey varchar2(200);

    NL VARCHAR2(1) := fnd_global.newline;

    BEGIN

    v_itemtype := substr(p_document_id, 1, instr(p_document_id, '|') - 1);

    v_itemkey := substr(p_document_id, instr(p_document_id, '|') + 1,

    length(p_document_id) - 2);

  • 7/27/2019 2 3 Peters

    31/38

    07/19/04 NorCal OAUG Training

    Day, Paper 2.3

    John Peters, JRPJR, Inc. 31

    PL/SQL CodeBuild Document (2)-- Portion of the Package ZZZZ_DEMO_WF_NOTIFICATIONS

    -- Procedure Create HTML Table Header

    if (p_display_type = 'text/html')

    then

    p_document := NL || '

    ';

    p_document := p_document || 'Employee Table';p_document := p_document || '';

    p_document := p_document || '';

    p_document := p_document || '' || NL;

    p_document := p_document || '' || 'EMPNO' || '';p_document := p_document || '' || 'ENAME' || '';

    p_document := p_document || '' || 'JOB' || '';

    p_document := p_document || '' || NL;

  • 7/27/2019 2 3 Peters

    32/38

    07/19/04 NorCal OAUG Training

    Day, Paper 2.3

    John Peters, JRPJR, Inc. 32

    PL/SQL CodeBuild Document (3)-- Portion of the Package ZZZZ_DEMO_WF_NOTIFICATIONS

    -- Procedure Create HTML Table Rows, Handle Text Document

    for arec in (select EMPNO,ENAME,

    JOB

    from scott.emp

    order by 2)

    loop

    p_document := p_document || '' || ''|| nvl(to_char(arec.EMPNO), '&nbsp') || '';

    p_document := p_document || '' || nvl(arec.ENAME, '&nbsp') || '';

    p_document := p_document || '' || nvl(arec.JOB, '&nbsp') || '

    || '' || NL;

    end loop;

    p_document := p_document || '';

    else

    p_document := 'Text Document Not Implemented';

    end if;

    END EMP_TABLE;

  • 7/27/2019 2 3 Peters

    33/38

    07/19/04 NorCal OAUG Training

    Day, Paper 2.3

    John Peters, JRPJR, Inc. 33

    Resulting Email Message

    This is the same email

    with the message body

    showing the contents

    of the table scott.emp.

  • 7/27/2019 2 3 Peters

    34/38

    07/19/04 NorCal OAUG Training

    Day, Paper 2.3

    John Peters, JRPJR, Inc. 34

    Warnings about Message Modification

    Workflow Messages are not versioned

    Notifications are versioned

    Adding new Attributes to a Message will affectall Workflows currently running immediately.

    If those Attributes are not derived you will get anerror.

    You should make a copy of a Workflow Messageif you will be adding Attributes to it.

  • 7/27/2019 2 3 Peters

    35/38

    07/19/04 NorCal OAUG Training

    Day, Paper 2.3

    John Peters, JRPJR, Inc. 35

    Workflow Versioning

    Workflow 1 starts with Version 1 Workflow 2 starts with Version 1

    If a message change is made in Version 2 it will

    affect both Workflows 1 & 2

    Workflow Loaded Ver 1 Workflow Loaded Ver 2

    Workflow Instance 1

    Workflow Instance 2

    Time

  • 7/27/2019 2 3 Peters

    36/38

    07/19/04 NorCal OAUG Training

    Day, Paper 2.3

    John Peters, JRPJR, Inc. 36

    Workflow Notification Testing Modify the Workflow Mailer Configuration using OAM

    Enter an email address for the Test Address

    This should be a common mail account or box that

    required users can view. User can then view this testemail box to find notifications from the test instance.

    Dont create an email distribution list and assign the

    required users to it. This causes confusion since emailsshow up in your email box and you have to read themcarefully to know if they are from PROD or not.

  • 7/27/2019 2 3 Peters

    37/38

    07/19/04 NorCal OAUG Training

    Day, Paper 2.3

    John Peters, JRPJR, Inc. 37

    Additional Reference Material

    Here are other papers I have written on Oracle

    Workflow. They are available for download

    from my web site: http://www.jrpjr.com

    Customizing Workflow: A technical perspective Oracle Alert and Workflow Comparison

    Oracle Workflow Tips and Tricks

    Requisition Approval Workflow Customizations

  • 7/27/2019 2 3 Peters

    38/38

    07/19/04 NorCal OAUG Training

    D P 2 3

    John Peters, JRPJR, Inc. 38

    My contact information:

    John [email protected]

    http://www.jrpjr.com

    Additional reference papers can be found at:http://www.norcaloaug.org

    http://www.norcaloaug.org/http://www.norcaloaug.org/