I have a excel sheet which has table as below
Value
AB
CD
EF
GH
IJ
if my input variable is contains the same value as the data table i should throw business exception
For example:
Input argument value is GH
since GH is present in excel throw business exception
Hi @sruthesanju ,
Could you Check with the below Expression :
DT.AsEnumerable.Any(Function(x)x("Value").ToString.Equals("GH"))
Here, DT
is your Input Excel sheet datatable. The above expression you could directly use it in an If
Activity. In then Block you could use the Throw
Activity.
Gokul001
(Gokul Balaji)
November 23, 2022, 6:00am
3
Hi @sruthesanju
Use Read Range activity → Store it in DtRead
Use Fore each row in data table activity
If activity
Currentrow("Value").Tostring.Trim.contains("GH")
Then → Use Throw activity → New BusinessRuleException("Your data")
Else → You can do your automation
Regards
Gokul
Instead of excel what if the values are added in assert
@sruthesanju Use get asset activity and use the value of asset inside the code. Inside if
Assetvalue.Trim.contains(“GH”) then throw business exception.
It will have value as AB,CD ,EF,GH will contains works can you suggest me any other method
@sruthesanju If the value in AB,CD ,EF,GH in single asset
1.Use get asset activity to get asset value
2.Assign ArrayAsset=Assetvalue.split(“,”)
For each item in array
check if Inputvalue.Trim.Contains(item) then throw business exception
Gokul001
(Gokul Balaji)
November 23, 2022, 6:26am
8
Hi @sruthesanju
In the Asset You can store the value like this AB,CD ,EF,GH
You can try with If activity and followed by below expression
(From d In DTInput1.AsEnumerable
Let b="GF"
Where Assetval.ToString.Trim.Contains(b)
Select d).any
Regards
Gokul
I am getting this error in if condition
Gokul001
(Gokul Balaji)
November 23, 2022, 6:43am
10
Have you tried with this expression ? @sruthesanju
will not be having any excel
Gokul001
(Gokul Balaji)
November 23, 2022, 6:45am
12
Hi @sruthesanju
Okay Just Create the dummy data table using Build data table activity and check the above expression
Gokul001
(Gokul Balaji)
November 23, 2022, 6:49am
14
Hi @sruthesanju
Try with this expression with out using excel Dt
(From d In Assetval.AsEnumerable
Let b="GF"
Where d.ToString.Trim.Equals(b)
Select d).any
Regards
Gokul
If the value is available in asset also it not through business exception
Gokul001
(Gokul Balaji)
November 23, 2022, 7:30am
16
Hi @sruthesanju
Check out this XAML file
AssetException.xaml (7.4 KB)
Regards
Gokul
system
(system)
Closed
November 26, 2022, 7:31am
17
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.