Data Service List object - how to get evaluate values from fields in a Data Service object?

I created a data service entity called “Suppliers” that has suppliername (string) and Active (yes/no) fields.

I have already imported Suppliers into my Studio project ready to use.

I’m using the Query Entity Records activity with the following:
EntityType: Myprocess.Suppliers
Query: suppliername=‘ABC’
Output Records: SupplierInfo

I understand SupplierInfo is a list .

My next activity is to evaluate if SupplierInfo.Active is Yes in order to execute the rest of the activities. Otherwise quit. How do I do this?

Hi @klazaro,

If you are expecting only one record to return from the query activity the easiest way will be to use the First() property of returned list.

You can use an If activity with the following condition

SupplierInfo.Count >0 AND SupplierInfo.First().Active.Value = True

You can write remaining activities in the Then block and your quit path in the Else block of the If activity

If you expecting multiple records to return from the query, then using a For Each activity is the suggested way.

You will set the following properties on the activtiy.

  • TypeArgument - Myprocess.Suppliers
  • Values - SupplierInfo

Now, within the Body, the item variable will be of type Suppliers and you can access it’s properties like item.suppliername and item.Active.

The For Each activity will loop through all the records that are returned by your query activity.

1 Like

By the way, I just realized that an easier way to handle this may be add the condition for Active = True in the Query activity itself. The Query activity support multiple conditions and allows you to select if you want to apply All (AND) conditions or Any (OR) of the conditions when fetching records.

If you set the Active = True condition in the query, you just need to make sure that SupplierInfo.Count = 1 and after that you can refer the returned supplier by using SupplierInfo.First().

When I used that if condition, I have a Compiler error: "Option Strict On disallows implicit conversions from ‘Boolean?’ to ‘Boolean’.

Do you know how to resolve this error?

My bad, please make that as SupplierInfo.First().Active.Value

I applied both of your recommendations: Query with “and” and changed the if statement with the SupplierInfo.Count = 1 condition only. Also, SupplierInfo.First().Active.Value = True worked. Thank you!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.