Questions and discussion about using ProcessMaker 2: user interface, running cases and functionality
Forum rules: Please search to see if a question has already been asked before posting. Please don't ask the same question in multiple forums.
By hoanghuynh
#812796
Hi All,

We have a requirement to avoid duplication of Task number (Which is an text box). To solve this issue i have created a report table by considering Task number as Unique key. I clicked on New Case, and try to provide duplicate Task number and the system has restricted the same, but an error is displayed. It is not allowing me to create a new case , Draft. I am looking for a solution to overcome this.

I am ideally looking for a solution by providing a pop-up message stating 'Task with the entered Task number is already created'. Also, the system should not restrict creating of New case or draft.

Please find below the error displayed by the tool
Error
Unable to execute UPDATE statement. [wrapped: Could not execute update [Native Error: Duplicate entry '8891' for key ' UNIQUE'] [User Info: UPDATE PMT_E2BNEWTABLE SET `TASKNO` = '8891' WHERE PMT_E2BNEWTABLE.APP_UID='118011474569f2b83460817028224164']]

and while clicking on inbox below error page will diaplay



RuntimeException:

The row '326873779568e5c32ebdcb3038267902, 2' in table AppDelegation doesn't exist!

At AppDelegation->Load()
in C:\Users\vijayalakshmi_m\AppData\Roaming\ProcessMaker-3_0_1_5_community\processmaker\workflow\engine\classes\class.case.php line 1173
At Cases->loadCase()
in C:\Users\vijayalakshmi_m\AppData\Roaming\ProcessMaker-3_0_1_5_community\processmaker\workflow\engine\methods\cases\open.php line 135
At require_once() in C:\Users\vijayalakshmi_m\AppData\Roaming\ProcessMaker-3_0_1_5_community\processmaker\workflow\public_html\sysGeneric.php line 1006
At include() in C:\Users\vijayalakshmi_m\AppData\Roaming\ProcessMaker-3_0_1_5_community\processmaker\workflow\public_html\app.php line 61


Regards,
Vijaya
User avatar
By amosbatto
#812804
You can create a trigger that automatically generates the taskNumber. For example:
Code: Select all
$sql = "SELECT (COALESCE(MAX(TASK_NUMBER), 0) + 1) AS NEW_TASK_NUMBER FROM PMT_MY_TASKS";
$aResult = executeQuery($sql);
@%taskNumber = $aResult[1]['NEW_TASK_NUMBER']; 
Set this trigger to execute when a new case is created in the Process Properties.

If you want the user to manually enter the taskNumber, then use trigger code like this:
Code: Select all
if (empty(@@taskNumber)) {
   $formId = '1234567890abcde1234567890abcde'; //set to ID of Dynaform
   PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $formId);
}

$num = @%taskNumber; //if integer
$sql = "SELECT * FROM PMT_MY_TASKS WHERE TASK_NUMBER=$num";

//if taskNumber is a char or varchar field, then use this code instead:
//$num = mysql_real_escape_string(@@taskNumber);
//$sql = "SELECT * FROM PMT_MY_TASKS WHERE TASK_NUMBER='$num'";

$aResult = executeQuery($sql);
if (!is_array($aResult)) {
   throw new exception("Error in query: $sql");
}
elseif (count($aResult) > 0) {
   PMFCancelCase(@@APPLICATION, @%INDEX, @@USER_LOGGED);
   die("This case #" .@@APP_NUMBER. " was <font color=red>canceled</font> because task '$num' already exists.");
}   
Set this trigger to fire at some point after the DynaForm where the user enters the taskNumber.

Hello. For rental housing, there are software solu[…]

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]