Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
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 Throwaway
#795290
I have a few processes and instead of starting the main progress, they started a sub process and completed it.

The issue is that because it wasn't the main process, it didn't kick off the next process and it took a few days to finish those forms. Is there any way I can "kick" the form back or somehow start a new case and send all the data over?

The data can all be accessed in the review, so I assume the worst-case method here is copying all the data over manually.

Thanks in advance,
User avatar
By amosbatto
#812532
Throwaway,
You can prevent this in the future by marking the option "This a sub-process:" in the properties of the process. That way the process will not appear in the list when users go to Home > New.

I have created a sample process that you can use to copy data from one case to another case:
(32.46 KiB) Downloaded 265 times
Here is trigger code:
Code: Select all
//set to ID of Dynaform to redirect to
$dynaformId = '2408819365a307aaea160f6061114839'; 
$g = new G();

if (isset(@@action) and @@action == "COPY_DATA") {
    if (empty(@@fromCaseNo)) {
        $g->sendMessageText("Enter the case number to copy data from.", 'WARNING');
        PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);
    }
    if (empty(@@toCaseNo)) {
        $g->sendMessageText("Enter the case number to copy data to.", 'WARNING');
        PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);
    }
    
    $sqlFrom = "SELECT * FROM APPLICATION WHERE APP_NUMBER=".@@fromCaseNo;
    $sqlTo = "SELECT * FROM APPLICATION WHERE APP_NUMBER=".@@toCaseNo;
    
    $aFromCase = executeQuery($sqlFrom);
    if (!is_array($aFromCase) or count($aFromCase) != 1) {
        $g->sendMessageText("Case number ".@@fromCaseNo.
            " doesn't exist. Enter different 'Copy from case no.'.", 'WARNING');
        PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);
    }
        
    $aToCase = executeQuery($sqlTo);
    if (!is_array($aToCase) or count($aToCase) != 1) {
        $g->sendMessageText("Case number ".@@toCaseNo.
            " doesn't exist. Enter different 'Copy to case no.'.", 'WARNING');
        PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);
    }
    
    $c = new Cases();
    $aCaseInfoFrom =$c->LoadCase($aFromCase[1]['APP_UID']);
    $aCaseInfoTo = $c->LoadCase($aToCase[1]['APP_UID']);
    
    //unset the system variables to not copied to the other case:
    $aSystemVars = array('APPLICATION', 'INDEX', 'PROCESS', 'TASK', 'APP_NUMBER', 'PIN',
        'USER_LOGGED', 'ÜSR_USERNAME', 'SYS_SYS', 'SYS_LANG', 'SYS_SKIN', '__ERROR__');
    $aVars = $aCaseInfoFrom['APP_DATA'];
    
    foreach ($aSystemVars as $varName) {
        unset($aVars[$varName]);
    }
    
    $aCaseInfoTo['APP_DATA'] = array_merge($aCaseInfoTo['APP_DATA'], $aVars);
    $c->updateCase($aCaseInfoTo['APP_UID'], $aCaseInfoTo);
    
    $msg = count($aVars)." variables were copied from case #".@@fromCaseNo.
        " to case #".@@toCaseNo;
    $g->sendMessageText($msg, 'INFO');
    
    //reset variables:
    @@action = '';
    @@fromCaseNo = '';
    @@toCaseNo = '';
    
    PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);    
}
elseif (isset(@@action) and @@action == "CANCEL") {
    //reset variables:
    @@action = '';
    @@fromCaseNo = '';
    @@toCaseNo = '';
    
    PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);
} 
And here is the JavaScript code:
Code: Select all
$("#cancelButton").find("button").click(function() {
  $("#action").setValue("CANCEL");
});

$("#copyCaseData").find("button").click(function() {
  $("#action").setValue("COPY_DATA");
});
Create a new case and then use this process to copy the data to the new case. You can also adapt this code to use PMFNewCase() to create a new case with the case data.
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

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