Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderators: ArturoRobles, ArturoRobles

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By gregoakes
#791515
Apologies if this has been answered before and my searches aren't up to scratch... I am no coder so I appreciate your patience.

I have a process with 5 parallel tasks, not all of which are executed in any given case. I would like to count each time a task is executed in a report table so I can generate dashboards in Metabase. I want to be able to date stamp the count as well so that I can use Metabase to filter on different date parameters.

I would appreciate any advice on what might be the best way to do this.

Thanks in advance
Greg
User avatar
By amosbatto
#791545
You can't do this with Report Tables, but you can create a custom PM Table and then use triggers to write to that PM Table.

First create a PM Table named "PARALLEL_DATA", with the following fields:
CASE_ID (char with length 32)
CASE_NO (integer)
DATE_EXECUTED (datetime)
USER_ID (char with length 32)
USERNAME (varchar with length 64)
COUNT (integer)
[any additional data fields filled in your parallel task]

Then, add the following trigger to your process:
Code: Select all
$taskId = @@TASK;
$caseId = @@APPLICATION;
$caseNo = @@APP_NUMBER;
$userId = @@USER_LOGGED;
$username = @@USR_USERNAME;

$sql = "SELECT COUNT(*) AS COUNT FROM APP_DELEGATION WHERE 
   APP_UID='$caseId' AND TAS_UID='$taskId' AND DEL_THREAD_STATUS = 'CLOSED'";
$result = executeQuery($sql);
$count = $result[1]['COUNT'] + 1;
$sql = "INSERT INTO PMT_PARALLEL_DATA (CASE_ID, CASE_NO, DATE_EXECUTED, USER_ID, USERNAME, COUNT) 
  VALUES ('$caseId', $caseNo, NOW(), '$userId', '$username', $count)";
executeQuery($sql);
Set your trigger to execute before assignment in your parallel task.

Another way to do this is simply query the APP_CACHE_VIEW table in the database, and sort the results by the DEL_FINISH_DATE.
User avatar
By groakes
#793903
Thanks Amos (I thought I had replied earlier but my post disappeared - user error I guess :oops: ).

Querying the APP_CACHE_VIEW was definately the simplest way! But thanks for the code - I'll probably use it elsewhere...

cheers
Greg

The 500 Internal Server Error is the general catch[…]

Really very nice blog information for this one and[…]

This is a long, lengthy and cumbersome process. T[…]

Great read for when on the road. The book provides[…]