Hi,
I'm trying to retrieve a collection using EntitySchemaQuery but when try to assign it to a Parameter i get the following error:
System.NotSupportedException: EntityCollection
at Terrasoft.Core.Process.FlowEngineStateService.InternalSetValue[T](Guid processUId, String parameterPath, T value)
at Terrasoft.Core.Process.FlowEngineStateService.Terrasoft.Core.Process.IInternalProcessParameterStore.InternalSetParameterValue[T](Guid processUId, String parameterPath, T value)
at Terrasoft.Core.Process.ProcessInstanceParameterStore.SetParameterValue[TValue](String parameterPath, TValue value)
at Terrasoft.Core.Process.ProcessInstanceParameterStore.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.UsrGetLeadsBySalesCompanyMethodsWrapper.ScriptTask1Execute(ProcessExecutingContext context)
at Terrasoft.Core.Process.ProcessScriptTask.InternalExecute(ProcessExecutingContext context)
at Terrasoft.Core.Process.ProcessFlowElement.Execute(ProcessExecutingContext context)
Example code:
var salesCompanyId = Get<Guid>("InSalesCompany");
// Creating a query instance with the "Lead" root schema.
var esqLead = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "Lead");
esqLead.AddColumn("UsrSalesCompany");
esqLead.AddColumn("CreatedOn");
esqLead.AddColumn("UsrLeadPriority");
esqLead.AddColumn("Id");
esqLead.Filters.Add(esqLead.CreateFilterWithParameters(FilterComparisonType.Equal, "UsrSalesCompany.Id", salesCompanyId));
// Filters in the query filter collection will be combined with the logical OR operator.
esqLead.Filters.LogicalOperation = LogicalOperationStrict.Or;
var entities = Get<ICompositeObjectList<ICompositeObject>>("ReadActiveOverrides.ResultCompositeObjectList");
foreach(var entity in entities) {
Guid value;
var fromSalesCompanyId = entity.TryGetValue<Guid>("UsrFromSalesCompany", out value) ? value : Guid.Empty;
var toSalesCompanyId = entity.TryGetValue<Guid>("UsrToSalesCompany", out value) ? value : Guid.Empty;
if(fromSalesCompanyId == Guid.Empty){
throw new Exception($"fromSalesCompanyId it is an empty guid {entity.ToString()}");
}
if(toSalesCompanyId == Guid.Empty){
throw new Exception($"toSalesCompanyId it is an empty guid {entity.ToString()}");
}
esqLead.Filters.Add(esqLead.CreateFilterWithParameters(FilterComparisonType.Equal, "UsrSalesCompany.Id", fromSalesCompanyId));
}
/*
Select selectEsq = esqLead.GetSelectQuery(UserConnection);
throw new Exception(selectEsq.GetSqlText());
*/
var res = esqLead.GetEntityCollection(UserConnection);
Set("OutLeads", res);
Paremeter OutLeads is a Collection of Objects (EntityCollection)
Any help is appreciated