Questions and discussion about using ProcessMaker 2: user interface, running cases and functionality

Moderator: amosbatto

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 snosov
#783824
I posted the same topic on developers board because this issue can be resolved either by changing base code, or using JS in a workflow.

Hi all. There has been some discussion about the Steps menu that appears at the top of the case when it is opened in classic skin. This menu shows all steps (dynaforms) accessible to the user at that time. Notably, if you use dynaform conditions, the menu will show only those steps for which the conditions resolve to true. (This is a very powerful feature.) I found this very helpful in the latest process I am building because I have a variable number of forms to fill out depending on a field.

I know that I could hide the menu by:
(1) editing base code in ..\workflow\engine\menus\caseOptions.php (comment out line 32), or
(2) using the following javascript previously documented in "Accessing the Interface" wiki:
Code: Select all
function hideSteps() {
  if (top.frames['casesFrame'] && top.frames['casesFrame'].frames['casesSubFrame'] && 
        top.frames['casesFrame'].frames['casesSubFrame'].document.getElementById("stepsMenu")) {
     top.frames['casesFrame'].frames['casesSubFrame'].document.getElementById("stepsMenu").style.display = "none";
     window.clearInterval(saveInterval);
  }
}
saveInterval = window.setInterval(hideSteps, 100);
What I want to do is to refresh/recalculate this menu after I derivate the case to a new task and open it using the following code in a trigger:
Code: Select all
  $caseId = @@APPLICATION;
  $nextId = @%INDEX+1;
  //$link = "Location: cases_Open?APP_UID=".$caseId."&DEL_INDEX=".$nextId."&action=draft";
  //G::SendMessageText($link, "WARNING");
  PMFDerivateCase(@@APPLICATION, @%INDEX);
  G::header("Location: cases_Open?APP_UID=$caseId&DEL_INDEX=$nextId&action=draft");
  die;
At this point, if a user opens the task from the inbox, the steps menu properly shows the accessible steps. However, when the case is derivated and opened automatically with the trigger, the steps menu retains info from the previous task, and if those tasks are clicked causes the following error:

Fatal error: Call to a member function getStepMode() on a non-object in C:\Program Files (x86)\Processmaker\processmaker\workflow\engine\methods\cases\cases_Step.php on line 266

Please Help!
Last edited by snosov on Wed Aug 12, 2015 2:44 pm, edited 1 time in total.
By snosov
#783939
This issue is still not resolved.

A couple of pointers to designers who want to route the same user through multiple tasks without stopping over at the derivation form, or forcing the user to go to the inbox.

1. Create an empty dynaform and call it something like "Route to next task". Then add this screen as a last step in your task. Add a trigger "RouteToNextStepAndDie" to execute BEFORE "Route to next task" step with the following logic:
Code: Select all
  $caseId = @@APPLICATION;
  $nextId = @%INDEX+1;
  PMFDerivateCase(@@APPLICATION, @%INDEX);
  G::header("Location: cases_Open?APP_UID=$caseId&DEL_INDEX=$nextId&action=draft");
  die;
This strategy takes care of the issues with populating case variables in the triggers that immediately precede the RouteToNextStepAndDie trigger. I personally had many issues, root cause of which I don't fully understand.

2. The logic above will work if the task is properly assigned to the logged in user. Thus, in the assignment rules for the task you will need to select "Value Based Assignment" and set the "Variable for Value Based Assignment" to @@USER_LOGGED.

3. The outstanding issue is with the Steps menu. I have many steps (dynaforms) in my task. Depending on a case variable I need to have the user fill out a variable number number of forms. Furthermore, I do not force the user to do it in a specific sequence -- user is free to jump from one form (dynaform step) to another using some sort of navigation menu. The "Steps" menu available in the classic skin is exactly what I need because it pre-calculates which steps will be available to user by evaluating the steps' "Conditions". Imagine a process consisting of 2 tasks: (Task1) User must select a type of case he is working on, for example civil, criminal, family, immigration, or some other. I set a case variable caseType = "immigrantion"
(Task2) Contains multiple dynaforms that need to be filled out for each type of case. For example, "Fee Agreement", "Contact Information", "I-130", "Complaint", "Rule 11 Motion", etc. Each form relates to one or multiple areas of law. To display only appropriate forms for the specific case type I create the following conditions:

"Contact Information" strpos('~civil~criminal~family~immigration~',"~"[email protected]@caseType."~") !== false
"Fee Agreement" strpos('~civil~criminal~family~immigration~',"~"[email protected]@caseType."~") !== false and @@proBono != 1
"I-130" strpos('~immigration~',"~"[email protected]@caseType."~") !== false
"Complaint" strpos('~civil~family~',"~"[email protected]@caseType."~") !== false
"Rule 11 Motion" strpos('~criminal~',"~"[email protected]@caseType."~") !== false

As a result, if the operator selects "civil" case type and not ProBono, s/he will be presented with the following set of the forms: Contact Information, Fee Agreement, Complaint.
Conversely, if the case is an "immigration" ProBono case, the operator will be presented with: Contact Information, I-130.

4. THE OUTSTANDING ISSUE
The Steps menu does not recalculate/refresh with the new set of steps when the user is routed to the next task using this logic. Has anyone solved it? I see this question was first posed a few years ago here:
http://forum.processmaker.com/viewtopic ... 35#p783935

Processmaker team, liliana, amosbatto, or anyone else:
there is an AjaxListener at:
../sysworkflow/en/neoclassic/cases/ajaxListener?action=steps. But I don't know how to invoke this so that my target (Steps Menu) gets refreshed. Help is urgently needed!
Last edited by snosov on Thu Dec 10, 2015 1:49 pm, edited 1 time in total.
By snosov
#784542
Still not a single reply! Can anyone answer the question how to force refresh the steps menu?

Thanks Amos, it kinda of worked. But the API respo[…]

Data table in the panel

Create a hidden field associated with the variab[…]

Timo, that code has been moved to: workflow/engine[…]

routeCase SOAP API error

There is no web service function to get all the va[…]