Wednesday, May 28, 2008

Workflow Business Events API's Part 1

We were having some issues with our OA Framework forms and needed to create Business Events and subscriptions for testing. I was reading through the Oracle Workflow API Reference and found the following API's:

  1. wf_events_pkg
  2. wf_event_subscriptions_pkg
Each of these has 2 useful functions/procedures, generate and receive. The generate function will generate an XML document that can be used later to recreate the event or subscription. In order to use the generate function, you will need to GUID (Global Unique ID) for the event and subscription. You can get the guid's from the wf_events and wf_event_subscriptions tables with the following query:

SQL> select we.guid EVENT_GUID, wes.guid SUBSCRIPTION_GUID
2 from wf_events we
3 , wf_event_subscriptions wes
4 where we.name = 'oracle.apps.ar.hz.CustAccount.create'
5 and wes.event_filter_guid = we.guid
6 and wes.status = 'ENABLED';

EVENT_GUID SUBSCRIPTION_GUID
-------------------------------- --------------------------------
89F5D0A2F6F7318CE03408002092A95D 204EC03F44A3198DE0440003BACE26A6

SQL>

Below is an example of using the generate function, and sample output with the GUID's from above:

SQL>
SQL> DECLARE
2 l_xml varchar2(32767);
3 l_guid raw(16) := '89F5D0A2F6F7318CE03408002092A95D';
4 begin
5 l_xml := wf_events_pkg.generate(x_guid => l_guid);
6 insert into t values (l_xml);
7 commit;
8 end;
9 /

PL/SQL procedure successfully completed.

SQL>
SQL> select * from t;

<wf_table_data>
<wf_events>
<version>1.0</version>
<guid>#NEW</guid>
<name>oracle.apps.ar.hz.CustAccount.create</name>
<type>EVENT</type>
<status>ENABLED</status>
<generate_function>
<owner_name>Oracle Trading Community</owner_name>
<owner_tag>AR</owner_tag>
<customization_level>L</customization_level>
<licensed_flag>Y</licensed_flag>
<java_generate_func>
<display_name>oracle.apps.ar.hz.CustAccount.create</display_name>
<description>oracle.apps.ar.hz.CustAccount.create</description>
</java_generate_func>
</generate_function>
</wf_events>
</wf_table_data>

SQL>
SQL> declare
2 l_xml varchar2(32767);
3 l_guid raw(16) := '204EC03F44A3198DE0440003BACE26A6';
4 begin
5 l_xml := wf_event_subscriptions_pkg.generate(x_guid => l_guid);
6 insert into t values (l_xml);
7 commit;
8 end;
9 /

PL/SQL procedure successfully completed.

SQL>
SQL> select * from t;
<WF_TABLE_DATA>
<WF_EVENT_SUBSCRIPTIONS>
<VERSION>1.0</VERSION>
<GUID>204EC03F44A3198DE0440003BACE26A6</GUID>
<SYSTEM_GUID>1B752B538AE54333E0440003BAB24929</SYSTEM_GUID>
<SOURCE_TYPE>LOCAL</SOURCE_TYPE>
<SOURCE_AGENT_GUID/>
<EVENT_FILTER_GUID>oracle.apps.ar.hz.CustAccount.create</EVENT_FILTER_GUID>
<PHASE>500</PHASE>
<STATUS>ENABLED</STATUS>
<RULE_DATA>KEY</RULE_DATA>
<OUT_AGENT_GUID/>
<TO_AGENT_GUID/>
<PRIORITY>50</PRIORITY>
<RULE_FUNCTION>hz_event_elt.hz_param_delete</RULE_FUNCTION>
<JAVA_RULE_FUNC/>
<STANDARD_TYPE/>
<STANDARD_CODE/>
<ON_ERROR_CODE/>
<ACTION_CODE/>
<WF_PROCESS_TYPE/>
<WF_PROCESS_NAME/>
<PARAMETERS/>
<OWNER_NAME>Oracle Collections</OWNER_NAME>
<OWNER_TAG>IEX</OWNER_TAG>
<CUSTOMIZATION_LEVEL>L</CUSTOMIZATION_LEVEL>
<LICENSED_FLAG>Y</LICENSED_FLAG>
<DESCRIPTION>Oracle Collections updates Collectors by Territory.</DESCRIPTION>
<EXPRESSION/>
</WF_EVENT_SUBSCRIPTIONS>
</WF_TABLE_DATA>
SQL>

As you can see we can then make these events portable when migrating from one environment to the next using the XML generated here. In Part 2 I will cover the the receive or create functions, and show how you can create events and subscriptions using the API's.

0 comments:

Post a Comment