Workflow Engine and other public APIs throw a variety of user-defined exceptions to indicate specific Engine conditions. It is important that Workflow Developers and Administrators understand the meaning of these errors and know how to deal with them. In this post, we will cover some of the important Workflow Engine related errors and understand how to deal with them.
Engine Errors
3122: Duplicate item 'ITEM_TYPE/ITEM_KEY' could not be created
Error Code: WFENG_ITEM_UNIQUE
Cause: This error may be thrown from WF_ENGINE.CreateProcess when you attempt to create a new instance of a workflow item. This error indicates that the Item Type and Item Key combination you have used to launch a new workflow instance already exists.
Fix: Use an unique item key for that item type
3136: Item 'ITEM_TYPE/ITEM_KEY' cannot be accessed while synchronous process in progress.
Error Code: WFENG_SYNCH_ITEM
Cause: This error may be thrown from WF_ENGINE.CreateProcess when attempt to create a new synchronous workflow instance while another synchronous workflow instance is already running in the same session. All synchronous workflow instances are created with item key #SYNCH to make sure the workflow instances starts and completes in the same session.
Fix: Wait till the existing synchronous workflow instance completes before creating another one.
3146: Commit happened in activity/function 'ACTIVITY/FUNCTION'
Error Code: WFENG_COMMIT_INSIDE
Cause: While a workflow instance was executing, a commit was issued inside a PLSQL procedure associated to a workflow function activity before or after an error occurred in that PLSQL procedure. The Workflow Engine traps errors produced by function activities by setting a savepoint before each function activity. If an activity produces an unhandled exception, the engine performs a rollback to the savepoint, and sets the activity to the ERROR status.
Fix: You should never commit within the PL/SQL procedure of a function activity. The Workflow Engine never issues a commit as it is the responsibility of the calling application to commit.
How to Catch these Errors?
Each error above is associated to an Error Code. Within your PLSQL code, you should following method to capture the specific error based on the error code to act on it.
begin
Wf_Engine.CreateProcess('ITEM_TYPE', 'ITEM_KEY', 'PROCESS_NAME');
exception
when others then
if (wf_core.error_name = 'WFENG_ITEM_UNIQUE') then
-- Item already exists, use a unique item key
Wf_Engine.CreateProcess('ITEM_TYPE', 'ITEM_KEY', 'PROCESS_NAME');
end if;
end