Recently, I was asked what ACTID was and how to find it. A user was trying to call some custom code which was usually invoked by Workflow to debug it, but ACTID is a mandatory parameter to the call.
What is ACTID?
The ACTID parameter is used to pass the internal ID for each Activity to the PL/SQL code for that Activity. When the Workflow Engine moves to a new Activity, it retrieves the unique identifier for that particular use of the Activity in the process, and passes it to the PL/SQL for that Activity.
Actually, ACTID is only required by the code if it references any Activity Attributes – the API to retrieve the Activity Attribute values needs to know exactly which use of that Activity we are currently running, so it needs to have the ID passed into the code. If the PL/SQL that you are going to call for that Activity does not reference any Activity Attributes, then for debug purposes you can actually pass in any value at all, since it won’t be used.
How do I find ACTID?
Ignoring the scenario where you don’t really need to know what the Activity ID is, when you are debugging the module, you will probably need to find out what the current value is for that activity. To find it out, you will need to know the Item Type and Item Key for the process you are looking to debug, and you will also need to check the label for that Activity – not the display name or internal name, but the LABEL for that Activity. If you have used the Activity a number of times in the same process, then each label will be different because the Workflow Builder automatically adds a number to the end of the name when you include it in a process.
Once you have those pieces of information, the following SQL will return the Activity ID for you:
DECLARE ad DATE; ai NUMBER; rt VARCHAR2(30); vr NUMBER; rtid PLS_INTEGER; BEGIN WF_ITEM.root_process('&item_type', '&item_key', rt, vr); rtid := WF_PROCESS_ACTIVITY.RootInstanceId('&item_type', '&item_key', rt); ad := WF_ITEM.Active_Date('&item_type', '&item_key'); ai := WF_PROCESS_ACTIVITY.FindActivity(rtid, '&activity_label', ad); DBMS_OUTPUT.put_line('Activity id = '||TO_CHAR(ai)); END; /
You can find that in one SQL statement rather than relying on DBMS_OUTPUT by running the following command, which may be easier for you to run:
SELECT Wf_Process_Activity.FindActivity ( Wf_Process_Activity.RootInstanceId ( wfi.item_type , wfi.item_key , wfi.root_activity ) , 'activity label' , Wf_Item.Active_Date(wfi.item_type, wfi.item_key) ) actid FROM wf_items wfi WHERE item_type = 'item type' AND item_key = 'item key' /
Hope that’s clear, but if not feel free to post a comment!