Uploaded image for project: 'Red Hat Process Automation Manager'
  1. Red Hat Process Automation Manager
  2. RHPAM-106

List variable is converted to an array of Maps in a User Task if multiple forms is used in BPM Suite 6.4

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • 6.x.x
    • BPM Suite 6.4.2
      Using Multiple-Form for an User Task

    • Workaround Exists
    • Hide

      It will be needed to cast variable for an array of Maps as follows:

       java.util.Map[] objects = (java.util.Map[]) kcontext.getVariable("lista");
      
       if (objects != null && objects.length > 0) {
       
          for(int i = 0; i < objects.length; i++){
          System.out.println(objects[i]);
          } 
       } 
      
      

      Note that instead of calling the variable directly, for instance:

       java.util.Map[] objects = (java.util.Map[]) lista;
      

      you need to use kcontext:

       java.util.Map[] objects = (java.util.Map[]) kcontext.getVariable("lista");
      

      Otherwise you will get an error during build&deploy stating that you can not cast from List to Map[] as the variable has been defined as a List.

      Show
      It will be needed to cast variable for an array of Maps as follows: java.util.Map[] objects = (java.util.Map[]) kcontext.getVariable( "lista" ); if (objects != null && objects.length > 0) { for ( int i = 0; i < objects.length; i++){ System .out.println(objects[i]); } } Note that instead of calling the variable directly, for instance: java.util.Map[] objects = (java.util.Map[]) lista; you need to use kcontext: java.util.Map[] objects = (java.util.Map[]) kcontext.getVariable( "lista" ); Otherwise you will get an error during build&deploy stating that you can not cast from List to Map[] as the variable has been defined as a List.
    • Hide

      1. Import myreproducer.git to your business-central;
      2. User Task is assigned to "brmsuser" Actor, so change it for your own or create a brmsuser;
      3. Build&Deploy project;
      4. Start myTest process definition;
      5. Go to Task page and start/complete "MyTask" User Task;
      6. In server log you should see:

       10:46:58,331 INFO  [stdout] (http-127.0.0.1:8080-6) [Ljava.util.Map;@72e58f81
      
      

      As you can see it is printing out an array of Maps instead of a List.

      Show
      1. Import myreproducer.git to your business-central; 2. User Task is assigned to "brmsuser" Actor, so change it for your own or create a brmsuser; 3. Build&Deploy project; 4. Start myTest process definition; 5. Go to Task page and start/complete "MyTask" User Task; 6. In server log you should see: 10:46:58,331 INFO [stdout] (http-127.0.0.1:8080-6) [Ljava.util.Map;@72e58f81 As you can see it is printing out an array of Maps instead of a List.

      The following process definitions throws a "java.lang.ClassCastException: [Ljava.util.Map; cannot be cast to java.util.List" by trying to print out a List variable in a Script Task:

      Start Event -> ScriptTask1 -> UserTask -> ScriptTask2 -> End event

      This process contains a List variable named "lista". In ScriptTask1, "lista" is populated... then you will be able to add new items for it in User Task (user task makes use of a multiple form to achieve it)... finally in last ScriptTask2 the lista variable should be printed out, but the error is thrown.

      After performing further tests we could confirm that in fact the multiple form is converting from a List to an array of Map types. Please see steps to reproduce.

              rh-ee-pefernan Pere Fernandez Perez
              rhn-support-ajuricic Amana Juricic
              Juraj Soltes Juraj Soltes (Inactive)
              Juraj Soltes Juraj Soltes (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: