An error happened while submitting the task form : SPIN/JACKSON-JSON-01004 Unable to find 'myList'


#1

Hi to all.

When I click to submit my task form in Tasklist, I see the following server error:
An error happened while submitting the task form : SPIN/JACKSON-JSON-01004 Unable to find 'myList’
To be more specific, “myList” is a defined variable (in which I’ve saved a created JSON Array) in my Script Task.
For more detail I attach here a screenshot of my bpmn diagram and my server log file:

catalina.2018-09-04.log (68.2 KB)

Thank you in advance,
Steve


#2

Hi @steftriant
I suspect you define collection property of Select from the list of products task to ${myList}. Try ${myList.elements()}. If it does not help you please upload bpmn definition.


#3

Hi @Kikol.

Thanks for your feedback :slightly_smiling_face:
I am going to try your suggestion but I have a question here.
In Collection field of Select from the list of products Multi-Instance Task I had already defined this expression:
${assignees.prop(‘representatives’).elements()}
, where “representatives” is the collection in which I’ve injected the “myList” variable at the Script Task.
So, do you know how could I define the above expression in Collection field?

Thanks,
Steve


#4

Sorry but I do not understand what you do. Representatives should represent your collection and I do not know where do you inject myList variable. Could you upload your diagram?


#5

Hi @Kikol.

Please let me explain my process scenario:

In the 1st user task (Create a list of products), the assignee user (who is the Central Administrator here) creates (via camForm function) a JSON Array named product.

On the submission of the 1st task form I want to automatically assign 1 instance of the User Task (Select from the list of products), to each user of the group Representatives.

So, in the Script Task (Create a list of users), I’ve written the following inline script:

var myList = product
var representatives = {"myList" : myList}
var mySpin = S(JSON.stringify(representatives));
execution.setVariable('assignees', mySpin.prop('myList').elements());  

JSON Array product is saved into the variable myList.
myList variable is then injected into a collection variable named representatives.

In the Multi-Instance user task (Select from the list of products), a group of 27 users (with the role Representative) have to select from the same list (array) of products.

2 screenshots from my Multi-Instance User Task Properties Panel:

I also uploaded my bpmn file in case you want to check sth:

example.bpmn (5.4 KB)

Thanks a lot for your help,
Steve


#6

Hi @steftriant ,
I’m not sure I understand what you want to achieve. Your script task simple creates a mySpin variable which is a simple collection of products, nothing else. So, you have to set collection property of multi instance task to ${assignees}. Then collection element (assignee) represents an instance of product created within first user task.


#7

Hi @Kikol.

Thanks for your feedback. :slightly_smiling_face:
The only thing that I want to achieve here is to automatically assign 1 only instance from the Multi-Instance User Task (Select from the list of products) to each one of the users who belong to the same group (Representatives in my process).
I tried anything you said but whenever I try to submit the 1st task form (Create a list of products), I always take the same server error message: SPIN/JACKSON-JSON-01004 Unable to find 'myList’ :confused:

Steve


#8

Hi @steftriant
Sorry, I focus on multi instance task . Your variable myList must be defined as a list. I replace your script as follows(and remove form references)

var myList =  ["product1","product2","product3"]
var representatives = {"myList" : myList}
var mySpin = S(JSON.stringify(representatives));
execution.setVariable('assignees', mySpin.prop('myList').elements());  

Only first line is changed:
var myList = product
I do not know that product means here. If this is a function then it which should return an array. If this is a process variable set by form then you should read it using execution.getVariable method.


#9

Hi @Kikol.

Let me attach here the script from my 1st html task form in order to understand the meaning of product .

<script cam-script type="text/form-script">
    			var product = $scope.product = [];                              																																				// Custom JavaScript creates a JavaScript Object and binds it to the current AngularJS $scope of the form as a variable named "product".
    			$scope.addProduct = function () {                              																																					// We make a function named "addProduct".
     				var product = {};                                 																																							// We add a new "product" to the Array.
     				product.Category = $scope.Category;
     				product.Description = $scope.Description;
     				if (!!$scope.camForm.fields[0].element[0].files[0]) {                        																																// If the file is uploaded,
      					product.Details = $scope.camForm.fields[0].element[0].files[0].name;                   																													// it returns file's "name".
     				} else {                                   																																									// If the file is not uploaded,
      					return;                                   																																								// it returns "undefined".
     				}
     				product.Price = $scope.Price;
     				$scope.product.push(product);                              																																					// We use the value of the "product" input field to add a new "product" to the Array.
     				$scope.Category = "";                                																																						// We clear the TextBox "Κατηγορία".
     				$scope.Description = "";                               																																						// We clear the TextBox "Περιγραφή".
     				$scope.Details = "";                                																																						// We clear file's "name".
     				$scope.Price = "";                                 																																							// We clear the TextBox "Τιμή (€)".
    			};
    			$scope.removeProduct = function (index) {                            																																			// We make a function named "removeProduct".
     				var category = $scope.product[index].Category;                          																																	// We find product's "Category" using "index" from the Array and binds it to the current AngularJS $scope of the form as a variable named "category".
     				$scope.product.splice(index, 1);                             																																				// We use an "index" to remove a "product" from the Array.
    			}
    			$scope.isAddFormValid = function () {                             																																				// We make a function named "isAddFormValid".
     				return ($scope.Category &&
          					$scope.Description &&
       						$scope.camForm.fields[0].element[0].files[0] &&
       						$scope.Price) ? true : false;                            																																			// If all of the 4 input fields of variable "product" are filled in, the "isAddFormValid" function (expression) returns "true", otherwise the function returns "false".
    			}
    			camForm.on('form-loaded', function() {                             																																				// We hook into the lifecycle of Camunda SDK JS Form.
     				camForm.variableManager.createVariable ({                           																																		// We "create" (declare) a new "process variable"
      					name:'product',                                 																																						// named 'product' and
      					type:'json',                                 																																							// provide as type information 'json' used for serialization.
      					value:product
     				});
    			});
    			camForm.on('submit', function(evt) {                             																																				// We hook into the lifecycle of Camunda SDK JS Form.
  					if (product.length<1) {                                																																						// If no "product" is added to the Array,
      					evt.submitPrevented = true;                              																																				// an event handler prevents the form from being submitted by setting the property "submitPrevented" to 'true'.
     				}
    			});																																																				 
   			</script>

So, product is the created process variable (via camForm function) and is a JSON array from the UI of the 1st user task form (Create a list of products).

So, in the 1st line of the script into the Script Task (Create a list of users), based on your last reply, I wrote this one:

var myList = ["product"]

I tried to submit again my task form with both of the 2 methods (execution.setVariable & execution.getVariable) but unfortunately without any success again :confused:
I took again the same server error message as previously here.

Thanks a lot,
Steve