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.
#31040
Hi,
I've been thinking on a solution to reuse existing case data into a new case.

For this example we generally collect specifications and client information throughout the course of a process. Then wanting to reuse that data without re-entering would be an advantage, there would be only minimal changes to loaded case info, new dates, some other minor variation.

At this point I'd try to use a simple dynaform and a new task for the existing process that accepts the case number to clone then use a trigger to collect the JSON data from the workflow table and either
1: update the current case record in the workflow table with the data (overwriting any existing info)
2: manually trying to assign/parse the loaded case variables within the trigger to the current case

I think the first option would take less work and is likely to work, i think that most the other data about the case (dates/users/case history) are stored elsewhere and would just be blank while the case is routed throughout the rest of the process.

Any thoughts?
Cheers
#31114
Retrieving information from an existing case is very complicated. All the information of one Dynaform is stored in 1 field. For this reason it is not recommended. I would suggest you create a report table of PMTable and store the data there. Once it is stored it is very easy to pull the data from this tables.

Best Regards
Victor M Larrea
#778564
Hi
turns out this is easy

first setup a dynaform with a suggest field as such
Code: Select all
  <prevcase type="suggest" hint="Start typing the previous case" size="45" mode="edit" sqlconnection="workflow" maxresults="16" shownoresults="1" primary_key_type="0"><![CDATA[SELECT  DISTINCT APP_NUMBER , APP_TITLE, CONCAT( APP_TITLE, ' ', APP_NUMBER) from APP_CACHE_VIEW     ]]><en>Previous Case</en></prevcase>
add a button that uses the saveAndRefreshForm, this way you can display some of the results on the current dynaform so the user knows they have the right case, I also added a test field runtrigger so that I only run the load when the user clicks to load and if they make changes they aren't overwritten
Code: Select all
  <refresh_data type="button" onclick="changeValue("runtrigger","true"); saveAndRefreshForm(this);">
    <en>Load Data</en>
  </refresh_data>
then attach a trigger to execute after the dynaform is submit
Code: Select all
if (@@runtrigger == "true") {
	$caseNo = @@prevcase;      //lookup the case number for the case in the Case list
	$result = executeQuery("SELECT APP_UID FROM APPLICATION WHERE APP_NUMBER='$caseNo'");
	$caseUID = $result[1]['APP_UID'];

	G::LoadClass('case');
	$oCase = new Cases();                //Create a Cases object
	$aCase = $oCase->loadCase($caseUID); //Load case
	$aVariables = $aCase['APP_DATA'];    //Get the variables for that case 

	@@product = $aVariables['product'];

	$tot = count(@=product);
	for ($cnt = 1; $cnt <= $tot; $cnt++) {
		@=product[$cnt]['product_repeat'] = true;
		@=product[$cnt]['product_repeat_order'] = @=product[$cnt]['product_order_number'];
		@=product[$cnt]['product_order_number'] = null;
		// set nulls to 0
		@=product[$cnt]['product_quantity'] 		= @=product[$cnt]['product_quantity'] ?: 0;
		@=product[$cnt]['product_quantity_2'] 		= @=product[$cnt]['product_quantity_2'] ?: 0;
		@=product[$cnt]['product_cost_foreign'] 	= @=product[$cnt]['product_cost_foreign'] ?: 0;
		@=product[$cnt]['product_cost_foreign_2'] 	= @=product[$cnt]['product_cost_foreign_2'] ?: 0;
		@=product[$cnt]['sample_cost_foreign'] 		= @=product[$cnt]['sample_cost_foreign'] ?: 0;
		// reset old totals and required date
		@=product[$cnt]['product_sell_total'] = null;
		@=product[$cnt]['product_cost_total'] = null;
		@=product[$cnt]['product_margin_local'] = null;
		@=product[$cnt]['date_required'] = null;
	}
  	@@runtrigger = "false";
}
Remember to turn off the field that enables the trigger,
I had a grid in mine so I loop through it and clean some of the fields, eg had a lot of null entries, changed them to '0' :)

further to this I plan to use the conditional setup for the trigger so I can reuse the 'runtrigger' variable in other places where I need to conditionally run triggers.
#780998
Hello rundyz,

Great to see your reply and solution, I too was searching for the same.
I was thinking like, is it possible to recall the data from earlier case directly into current dynaforms as whole instead of setting one data at a time. Since I have many dyanforms with me and too many fields, its a tedious job to load each field individually.

So lets say something like a default trigger will run which will load the complete case when I set some default APP_UID (or any id) before executing the case.

Can you / anyone help me in implementing this.

Thanks in advance.
#781000
Hello rundyz,

Really nice to see your quick reply.
My requirement actually is exactly loading all the old APP_DATA from earlier customer's case, and then in one of the many dynaforms I need to change one single amount, that's it, so I need to load the old case as it is.

I am actually new to processmaker, and I tried setting APP_DATA directly into the current case using a before - trigger, but was not able to do it. Can you please guide me on this, on how exactly the whole APP_DATA colum data can be set in dynaform.
#781035
Hi Sure, glad to assist.


using the information in my earlier post you'll need a dynaform that lets you select a previous case.
Then using that previous case number in a trigger that fires after the dynaform is submit
Code: Select all
   $caseNo = @@prevcase;      //lookup the case number for the case in the Case list
   $result = executeQuery("SELECT APP_UID FROM APPLICATION WHERE APP_NUMBER='$caseNo'");
   $caseUID = $result[1]['APP_UID'];

   G::LoadClass('case');
   $oCase = new Cases();                //Create a Cases object
   $aCase = $oCase->loadCase($caseUID); //Load case
   $aVariables = $aCase['APP_DATA'];    //Get the variables for that case 
after the trigger $aVariables contains the entire APP_DATA
then you would need to set the current case's APP_DATA to $aVariables
Code: Select all
$_SESSION["APP_DATA"] = $aVariables;
Hope that this helps, there is also good information in the wiki http://wiki.processmaker.com/index.php/ ... le_Storage
#825178
Hi there !!!
I'm pretty new to Processmaker and it's Dynaform.
I have the same requirement mentioned earlier in this post, anyway I have no idea how to start.
Is that possible you can share an example in .pmx file?
Thank you

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]