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

Moderator: 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 Skipper

is it possible to implement a function in a case to start a new case with the same variable values as an old completed case?

Kind regards.
User avatar
By amosbatto
If you want to clone a case which starts from the same task as the existing case, then you can use this process:

If you want to create a new case that begins in the starting task but has the same values as an existing case, then you can use this process:
(28.5 KiB) Downloaded 179 times
Here is the trigger code that it uses:
Code: Select all
//set to ID of form where user selects case to copy:
$dynaformId = '3633777765a134ed6299f98068921314';

$g = new G();
if (empty(@@selectCase)) {
    $g->SendMessageText("Please enter the number of the case whose values should be copied.",
    PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);
$caseNo = @@selectCase;
$aResult = executeQuery($sql);
if (!is_array($aResult) or count($aResult) == 0) {
    $g->SendMessageText("Unable to find case number $caseNo in the APP_CACHE_VIEW table.", 
    PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);

$caseId = $aResult[1]['APP_UID'];
$oCase = new Cases();
$aCase = $oCase->LoadCase($caseId);

//delete system variables from old case before copying to the new case:
$aSystemVars = array('SYS_SYS', 'SYS_SKIN', 'SYS_LANG', 'APPLICATION', 'APP_NUMBER', 
foreach ($aSystemVars as $var) {
$newCaseId = PMFNewCase($aResult[1]['PRO_UID'], $aResult[1]['USR_UID'],
                        $aResult[1]['TAS_UID'], $aCase['APP_DATA']);

if (!empty($newCaseId)) {
    $aCase = $oCase->LoadCase($newCaseId, 1);
        "New case {$aCase['APP_TITLE']} created in {$aResult[1]['APP_PRO_TITLE']} / ".
        "{$aResult[1]['APP_TAS_TITLE']} and assigned to {$aCase['CURRENT_USER']}.", 'INFO');
    PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);
else {
    $g->SendMessageText("Unable to create new case" . 
        (isset(@@__ERROR__) ? ":\n". @@__ERROR__ : ''), 'ERROR');
    PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);


sí, resolví esto creando un usuario […]

Error when importing any process

I still have the same error, need help please

Hi Expert, I need your advice urgently, currently[…]

Thanks very much.