What is ACTID and how do I find it?

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:

  ad   DATE;
  ai   NUMBER;
  rt   VARCHAR2(30);
  vr   NUMBER;
  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));

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!

By continuing to use the site, you agree to the use of cookies. more information

In common with almost all professionally run websites, this website logs the IP address of each visitor in order to keep it running reliably. This is also essential for protecting the website and its visitors from malicious attacks, including infection with malware.

This website provides information as a service to visitors such as yourself, and to do this reliably and efficiently, it sometimes places small amounts of information on your computer or device (e.g. mobile phone). This includes small files known as cookies. The cookies stored by this website cannot be used to identify you personally.

We use cookies to understand what pages and information visitors find useful, and to detect problems such as broken links, or pages which are taking a long time to load.

We sometimes use cookies to remember a choice you make on one page, when you have moved to another page if that information can be used to make the website work better. For example:
- avoiding the need to ask for the same information several times during a session (e.g. when filling in forms), or
- remembering that you have logged in, so that you don’t have to re-enter your username and password on every page.

You can prevent the setting of cookies by adjusting the settings on your browser (see your browser Help for how to do this). Be aware that disabling cookies will affect the functionality of this and many other websites that you visit.