klazaro
(Kelly Lazaro)
January 28, 2021, 7:06pm
1
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
ankit.saraf:
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 = True
You can write remaining activities in the Then block and your quit path in the Else block of the If activity
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()
.
klazaro
(Kelly Lazaro)
January 28, 2021, 7:48pm
5
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
klazaro
(Kelly Lazaro)
January 28, 2021, 9:07pm
7
ankit.saraf:
SupplierInfo.Count = 1
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
system
(system)
Closed
January 31, 2021, 9:07pm
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.