Script task Collection of Records does not work without subprocess

Dear sir, madam,

 

I have been troubleshooting this for a few hours and it is very frustrating. In one process it does work, in another it doesnt.

 

Apparently I found the problem, I am not sure if this is a bug of somesorts?

 

The following script is an example from: https://academy.creatio.com/docs/8-0/user/bpm_tools/process_elements_re…

var list = new CompositeObjectList<CompositeObject>();
var item1 = new CompositeObject();
item1["Id"] = Guid.NewGuid();
item1["Name"] = "Name1";
list.Add(item1);
var item2 = new CompositeObject();
item2["Id"] = Guid.NewGuid();
item2["Name"] = "Name2";
list.Add(item2);
Set<CompositeObjectList<CompositeObject>>("CompositeObjectListParameter", list);

I get the following error message

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Terrasoft.Core.Process.ProcessParameterProvider.SaveCollection(String parameterPath, ICompositeObjectList`1 items)
   at Terrasoft.Core.Process.ProcessParameterProvider.SetParameterValueInternal[TValue](String parameterPath, TValue value, Boolean setMustReadFromParameterStore)
   at Terrasoft.Core.Process.ProcessParameterProvider.UpdateParameterValue[TValue](String parameterPath, TValue value)
   at Terrasoft.Core.Process.ProcessParameterProvider.SetParameterValue[TValue](ProcessSchemaParameter parameter, Guid schemaElementUId, TValue value)
   at Terrasoft.Core.Process.ProcessModel.SetParameterValue[T](FoundParameterData result, T value)
   at Terrasoft.Core.Process.ProcessModel.TrySetValue[T](ProcessSchema processSchema, String propertyPath, T value)
   at Terrasoft.Core.Process.ProcessModel.Set[T](String propertyPath, T value)
   at Terrasoft.Core.Process.UsrProcess_0ca90bfCustom1MethodsWrapper.ScriptTask1Execute(ProcessExecutingContext context)
   at Terrasoft.Core.Process.ProcessScriptTask.InternalExecute(ProcessExecutingContext context)
   at Terrasoft.Core.Process.ProcessFlowElement.ExecuteItem(ProcessExecutingContext context)
   at Terrasoft.Core.Process.ProcessFlowElement.Execute(ProcessExecutingContext context)

It only works when inserting the Collection of Records "CompositeObjectListParameter" parameters Id and Name into a subprocess.

If you do not 'connect' a subprocess it gives the error message.

 

Why is this? Is this a bug?

Like 0

Like

3 comments

Hello,

 

This can be fixed by creating the CompositeObjectListParameter in the following manner:

Id and Name are the "Title" and the "Code" of the nested parameters + it's important to set default values. As a result the code will work properly.

Hi Oleg

I tried what you suggest but it does not work.

In the subprocess arrives the initial default value configured on the parent business process not the values setted on the script task.

 

Can you help me?

 

Hi Stefano

Encountered the same issue that you described. After removing the default values in the parent process it started to work normally. Didn't see any negative effects.

Show all comments