Question

I have been struggling very much with handling collection type response parameters in web services.

When response parameters are or normal type they are very easy to handle in the business processes. Here we are able to handle them as parameters on the Call web service process element. And use these in the process right away.

When there is a Collection which is returned, this is very different. Now the Call web service element parameter is of type Collection of Objects with attributes.

It seems to me that this parameter-type is very difficult to handle in the business process. I can't seem to find documentation in the Academy about how to extract and loop through the contents of the Collection of Objects with attributes.

What I have found in the academy is this article about setting up the Web service.
https://academy.bpmonline.com/documents/administration/7-14/adding-resp…

What I need to learn is how to handle them in bpm'online business processes.
Is there something about this in the Academy?
Is writing source code the only option? It's difficult to debug.

Like

3 comments

Dear Julius,

Unfortunately, it is impossible to handle parameters that have the “collection of object” type without using the source code.

Therefore, in this case we recommend using “ScriptTask” element for both calling the web-service and processing the results of call.

For more detailed assistance, please contact technical support.

Best regards,

Norton

Norton Lingard, Thank you. Is there anything like this in the academy? Because there is a special bpm'online syntax to go by in the source-code.

Dear Julius,

The service call in a "Script task” business process element can be implemented via native C#. Please find a lot of examples on how to do that in Google. For example, several links below:

https://stackoverflow.com/questions/9620278/how-do-i-make-calls-to-a-rest-api-using-c

https://code-maze.com/different-ways-consume-restful-api-csharp/

Please note that it is possible to use the native C# collections instead of working with the the special bpmonline collections.

Best regards,

Norton

Log in or register to comment
Question

Hi,

I'm trying to get a list of OpportunityFile associated with an OpportunityId and it's seems it's not possible using ODATA.

1. If I'm using this Url https://server.bpmonline.com/0/ServiceModel/EntityDataService.svc/Oppor… I'm getting a "Not Implemented" exception

<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<script/>
<code>4</code>
<message xml:lang="">Not Implemented</message>
<innererror>
<message>Not Implemented</message>
<type>System.Data.Services.DataServiceException</type>
<stacktrace>
at System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)
 at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService, IODataResponseMessage responseMessage)
 at System.Data.Services.DataService`1.HandleRequest()
</stacktrace>
<internalexception>
<message>Method 'SelectMany' not supported</message>
<type>System.NotSupportedException</type>
<stacktrace>
at Terrasoft.Core.Entities.EntityQueryProvider.VisitMethodCall(MethodCallExpression node)
 at Terrasoft.Core.Entities.EntityQueryProvider.Build(Expression expression)
 at Terrasoft.Core.Entities.EntityQueryProvider.LoadEntityCollection(Expression expression)
 at Terrasoft.Core.Entities.EntityQueryProvider.ExecuteEnumerable(Type elementType, Expression expression)
 at Terrasoft.Core.Entities.EntityQuery`1.GetEnumerator()
 at System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)
</stacktrace>
</internalexception>
</innererror>
</error>

2. If I'm using this Url https://server.bpmonline.com/0/ServiceModel/EntityDataService.svc/Oppor… eq guid'e14b9eb7-99ff-43a6-bf26-a60b23b3ec12') I'm getting the following exception:

<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<script/>
<code>1</code>
<message xml:lang="">Collection item with name OpportunityId not found.</message>
<innererror>
<message>Collection item with name OpportunityId not found.</message>
<type>Terrasoft.Common.ItemNotFoundException</type>
<stacktrace>
at Terrasoft.Core.Entities.EntitySchema.GetSchemaColumnByPath(String columnPath)
 at Terrasoft.Core.Entities.EntityQueryWhereBlockBuilder.CreateExpression(Expression node)
 at Terrasoft.Core.Entities.EntityQueryWhereBlockBuilder.CreateSimpleFilter(BinaryExpression binary)
 at Terrasoft.Core.Entities.EntityQueryWhereBlockBuilder.CreateFilter(Expression node)
 at Terrasoft.Core.Entities.EntityQueryWhereBlockBuilder.BuildBlock(MethodCallExpression node)
 at Terrasoft.Core.Entities.EntityQueryProvider.VisitMethodCall(MethodCallExpression node)
 at Terrasoft.Core.Entities.EntityQueryProvider.Build(Expression expression)
 at Terrasoft.Core.Entities.EntityQueryProvider.LoadEntityCollection(Expression expression)
 at Terrasoft.Core.Entities.EntityQueryProvider.ExecuteEnumerable(Type elementType, Expression expression)
 at Terrasoft.Core.Entities.EntityQuery`1.GetEnumerator()
 at System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)
 at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService, IODataResponseMessage responseMessage)
 at System.Data.Services.DataService`1.HandleRequest()
</stacktrace>
</innererror>
</error>

3. Also, if I'm using this Url https://server.bpmonline.com/0/ServiceModel/EntityDataService.svc/Oppor… eq guid'b3427cc4-3b20-4c16-8d2a-058ada7e7631') I'm getting a different error.

<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<script/>
<code>4</code>
<message xml:lang="">Syntax error at position 1.</message>
<innererror>
<message>Syntax error at position 1.</message>
<type>System.Data.Services.DataServiceException</type>
<stacktrace>
at System.Data.Services.Parsing.ExpressionLexer.ValidateToken(TokenId t)
 at System.Data.Services.Parsing.ExpressionLexer.ReadDottedIdentifier(Boolean allowEndWithDotStar)
 at System.Data.Services.RequestQueryProcessor.ReadExpandOrSelect(String value, Boolean select, IDataService dataService)
 at System.Data.Services.RequestQueryProcessor.ProcessSelect()
 at System.Data.Services.RequestQueryProcessor.ProcessQuery()
 at System.Data.Services.RequestQueryProcessor.ProcessQuery(IDataService service, RequestDescription description)
 at System.Data.Services.RequestUriProcessor.ProcessRequestUri(Uri absoluteRequestUri, IDataService service, Boolean internalQuery)
 at System.Data.Services.DataService`1.HandleRequest()
</stacktrace>
</innererror>
</error>

It seems the filtering is not working on associated collection entities. Do you have any ideas?

Regards,

Radu

Like

1 comments

Dear Radu,

Please see the example below. Draw your attention to the column OpportunityId syntax - Opportunity/Id

 

http://localhost:8006/0/ServiceModel/EntityDataService.svc/OpportunityF… = Opportunity/Id eq guid'410006e1-ca4e-4502-a9ec-e54d922d2c00'

 

Regards, 

Anastasia

Log in or register to comment
Question

Hello community!

I need get in a bussines process a collection parameter and then use that in a script task into a foreach. Any example about that?

 

Regards,

 

Like

1 comments

Dear Federico,

Please check the instructions on how to work with collections within [Read data element]. This will help you to implement your own process.

Algorithm of the work with a collection from Read data:

1.Disable the formula validator in business process designer. You can open the console and execute the following script for that:
var featureCode = "UseProcessFormulaServerValidation";
require(["FeatureServiceRequest"], function() {
                var featureRequest = Ext.create("Terrasoft.FeatureServiceRequest", {code: featureCode});
                featureRequest.updateFeatureState({
                               forAllUsers: true,
                               state: Terrasoft.FeatureState.DISABLED // ENABLED
                }, ()=>console.log("Done"));
});
 
2. In [Read data] element go to extended options and tick:
Read first = true
Number of records to read = 100 //Number of records available in a collection.

3. Create a process parameter with EntityCollection type and map it to the resulting collection of [Read data]. This parameter does not exist out of the box, but you can create it manually. 
Example:
[#MyRead.Resulting collection#]
*  MyRead – [Read data] element header.
* Resulting Collection - added manually
 
4. Assign a process parameter to a new variable in ScriptTask. Here is the example how to process the collection:
EntityCollection entities = Get("MyEntity");
var result = new Collection();
foreach(Entity entity in entities) {
                var cityName = entity.GetTypedColumnValue("Id");
                string temp = cityName.ToString();
                result.Add(temp);
                }
 
string displayValue = result.ConcatIfNotEmpty(",");
Set("MyResult", displayValue);
return true;
 
MyRead – reading datat in any element.
MyEntity process parameter with EntityCollection type. Parameter value= [#MyRead.Resulting collection#]
MyResult - string parameter. You can store record IDs from the collection. Then this parameter is shown on the auto generated page for the testing purposes.  

Best regards,

Lily

Log in or register to comment