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 fibo2358
#812399
Hello,

I would like to create a new case (based on some conditions in the process A) in the process B.
The most important thing is do this automatically, without any interactions from the users.
I tried to use a subprocess in the process A and invoke a process B in the subprocess properties.
However, I had to choose the starting activity in the process B.
I used an Empty Task as an only task in the process B but it required a click on this task to complete the new case.
I tried also a Script Task but it resulted in error (no userid)

Please help.
Best Regards,
fibo2358
#812402
Well, you could probably

1) Create a new case :
Code: Select all
PMFNewCase($processUID, $userID, $stepUID, array());  (pretty sure the $stepUID is the TAS_UID in the TASK table.

2) If for any reason you just want to set the status to 'COMPLETED' (skip this code if it's not the case):
Code: Select all
if ($newCaseUID) {
	$c = new Cases();
	$aCase = $c->loadCase(@@newCase);
	$aCase['APP_STATUS'] = 'TO_DO';
	$c->updateCase(@@newCase, $aCase);
}
else:

2) Redirect to the new case:
Code: Select all
G::header("Location: ../cases/cases_Open?APP_UID=$newCaseUID&DEL_INDEX=1&action=draft");
die();
3) Create a trigger 'before dynaform' in the subprocess before assignment(it doesn't need to be a subprocess by the way)
Code: Select all
PMFDerivateCase(@@APPLICATION, @%INDEX);
4) I don't know what you really need to do but you could probably put a trigger to redirect to the inbox (this trigger MUST be after the 'Derivate Case' trigger that you created at step 3.

Hope that helps a little bit!

Documentation: http://wiki.processmaker.com/3.0/ProcessMaker_Functions
User avatar
By amosbatto
#812409
To add to what stevensi1018 already said, you can look up the IDs in PROCESS.PRO_UID and TASK.TAS_UID fields in the database, but it is much easier to simply to run a case in your process B with Debug Mode activated and then copy the IDs of the PROCESS system variable and the ID of the TASK system variable when in the initial task of your process B. Then use this code:
Code: Select all
$processId = '1234567890abcde1234567890abcd';  //set to the ID of Process B.
$taskId = '1234567890abcde1234567890abcd';  //set to ID of initial task in the Process B
//set to the ID of one of the users assigned to the initial task in Process B
$userId = '1234567890abcde1234567890abcd'; 
PMFNewCase($processId, $userId, $taskId, array()); 
If the user isn't assigned to the initial task, then this function won't work.
By fibo2358
#812420
Hello stevensi1018 and Amos,

Thank you for your help.
I put the pieces together and applied some modifications ($newCaseUID instead of @@newCase and $aCase['APP_STATUS'] = 'COMPLETED' in example 2) and it works!

Best Regards,
fibo2358
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[…]