Professional Documents
Culture Documents
Creating WF Local Roles-2
Creating WF Local Roles-2
Adhoc roles can be created through PL/SQL from database or they can be created from Applications
using User Management Responsibility. If PL/SQL is used to create roles, all user names and role
names in UPPER case to avoid some errors:
DECLARE
vRole VARCHAR2(100) := 'XAOATESTROLE';
vRoleDesc VARCHAR2(100) := 'XAOATESTROLE';
BEGIN
wf_directory.createAdhocRole( vRole,
vRoleDesc,
NULL,
NULL,
'Test Role for All Oracle Apps users',
'MAILHTML',
'OPERATIONS', --USER NAME SHOULD BE IN
CAPS
NULL,
NULL,
'ACTIVE',
NULL
);
Result:
SELECT *
FROM WF_ROLES
WHERE name = 'XAOATESTROLE';
SELECT *
FROM WF_USER_ROLES
WHERE role_name = 'XAOATESTROLE';
SELECT *
FROM WF_LOCAL_ROLES
WHERE name = 'XAOATESTROLE';
SELECT *
FROM WF_USER_ROLE_ASSIGNMENTS
WHERE role_name = 'XAOATESTROLE';
DECLARE
vRoleName VARCHAR2(100);
vUserName VARCHAR2(100);
BEGIN
vRoleName := 'XAOATESTROLE';
vUserName := 'NAME3';
wf_directory.AddUsersToAdHocRole( vRoleName,
vUserName
);
--User names should be in CAPS
COMMIT;
END;
/
DECLARE
vRoleName varchar2(100);
vUserName varchar2(100);
BEGIN
vRoleName := 'XAOATESTROLE';
vUserName := 'NAME3';
WF_DIRECTORY.RemoveUsersFromAdHocRole ( vRoleName,
vUserName --User Name in CAPS
);
COMMIT;
END;
/
WF_ENGINE.CREATEPROCESS( itemtype,
itemkey ,
process
);
DBMS_OUTPUT.PUT_LINE('Work Flow Created with Itemkey: '|| itemkey||'
Itemtype: '|| itemtype);
--Code for setting the ItemAttribute Role which we have created.
--For setting the Number type Attribute use SetItemAttrNumber
WF_ENGINE.SetItemAttrText ( itemtype,
itemkey ,
'XAOA_TEST_ATTRIBUTE', --Item Attribute
Name
'XAOATESTROLE' --WF Role Name
); -- This can be set even in
Insert Procedure.
WF_ENGINE.STARTPROCESS ( itemtype,
itemkey
);
DBMS_OUTPUT.PUT_LINE('Work Flow Started with Itemkey: '|| itemkey||'
Itemtype: '|| itemtype);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE('Error at LAUNCH_WORKFLOW: '||SQLERRM);
END LAUNCH_WORKFLOW;
END XXAOA_TEST_WF_PKG;
/
Sample Code to test the workflow:
DECLARE
lvItemType VARCHAR2(80) := 'XAOATEST';
lvUserId NUMBER := -1;
lvItemKey VARCHAR2(10);
vErrorMsg VARCHAR2(2000);
vErrorCode NUMBER;
BEGIN
lvItemKey := 'XAOA6-12'; -- This should be unique value for this Itemtype
xxaoa_test_wf_pkg.launch_workflow( itemtype => lvItemType,
itemkey => lvItemKey,
process => 'AOAMAIN_PROCESS' -- Main
Runnable process name
);
COMMIT; -- Use commit if we need to see the WF Status from Front End from
workflow Admin Resp
EXCEPTION
WHEN OTHERS
THEN
vErrorCode := SQLCODE;
vErrorMsg := SQLERRM(SQLCODE);
RAISE_APPLICATION_ERROR(20001, vErrorMsg);
END;
/
Result:
SELECT *
FROM wf_item_attribute_values
WHERE item_type = 'XAOATEST';
SELECT *
FROM wf_items
WHERE item_type = 'XAOATEST';
SELECT *
FROM wf_item_activities_history_v
WHERE item_type = 'XAOATEST';
Once triggered See the below Approval Notification for either Workflow –> Notifications or directly on
the screen depending on the Profile Option setup:
Open the Notification:
Once Approved see the Activity history or Status Diagram from Status Monitor. This can be done at
any stage of the workflow once kicked off. Usually while debugging this is the first place we need to
check and then check in wf tables.
Some of the workflow tables:
WF_LOOKUP_TYPES_TL
WF_MESSAGES
WF_MESSAGE_ATTRIBUTES
WF_NOTIFICATION_ATTRIBUTES
WF_ITEM_ATTRIBUTES
WF_ITEM_ACTIVITY_STATUSES
WF_ITEM_ATTRIBUTE_VALUES