Input data available array variables :
Variable 1 : Arr_Code
Variable 2 : Arr_CompanyCode
DB Table stored in Datatable:
Requirement:
Need to validate if anyone of the value available in array Arr_Code variable is available in “Code” column in data table and also if anyone the value available in array Arr_CompanyCode variable is available in “CompanyCode ” Column in data table
If both values matches then stored in str_status as YES else No
Note : Attached DB table file for your reference
HMN_TSA_VENDOR_APPROVAL_MEXICO.xlsx (11.4 KB)
You need to convert the array in ‘A,B,C,D’ and move to db, then you convert this to data table and perform the logic in the database level because your data is already in the database
if you do this then your bot will me much faster then you put logic in local
Hello,
it is the second time that I was looking for a solution to transform an array of string to a datatable without using a for each loop. Since I didn’t find anything but found a solution here my advise:
Assign: Array of String → String{abc,def,ghi}
Assign: Convert array of string to a string → string.join(“?”,YourArray)
Chose your separator according to your problem. Shouldn’t be part of any of your strings in the array
Generate Datatable:
Newline separator = separator you chose bef…
@Sathish_Kumar_S I know its complex but its much faster
ppr
(Peter Preuss)
May 3, 2024, 11:44am
3
Sathish_Kumar_S:
Arr_CompanyCode
please share some sample values representing items from Arr_CompanyCode
For Arr_Code we would assume items like E110, F000…
Sure… Here is the some sample values
Arr_Code = E110 or E120 or E200 etc…
Arr_CompanyCode = 3105 or 3112 or 3113 or mexico
ppr
(Peter Preuss)
May 3, 2024, 1:00pm
5
just be more specific is it
String Array like {“3105 or 3112 or 3113 or mexico”, “12 or 15 or italy”}
Do you want to check for exact match like:
is
or only if 3105 as part of the company code
Any reasons why there is an derivation of & vs or and different letter cases?
I can create another table just for company code and the DT will look like below
or it is just 4 (3105,3112,3113,Mexico) values that we need to validate… We can hardcode these values in Bot code itself for validation
Attached both Dt… Please use as per your convenient.
CompanyCode.xlsx (9.6 KB)
Code.xlsx (11.2 KB)
Arr_CompanyCode and Arr_Code may contain multiple values or single values
Company code validation :
We need to validate if any one of the value available in Arr_CompanyCode is matching with DT CompanyCode column rows
Code Validation:
We need to validate if any one of the value available in Arr_Code is matching with DT Code column rows
How i am getting values to Arr_Code Array :
Input text : ProfessionalServices P000 , Human resource development 801115, HR Services P100 , Compensation/payroll P131
Using Regex to capture each values in BOLD and stored in Arr_Code
Example Value in Arr_Code = {“P000”,“P100”,“P131”} or {“P000”}
How i am getting values to Arr_CompanyCode Array :
Input text : Cocode 3105, Plant 0310, CoCode 3112
Using Regex to capture each values NEXT to CoCode and stored in Arr_CompanyCode
Example Value in Arr_CompanyCode = {“3105”,“3112”,} or {“3105”}
Anil_G
(Anil Gorthi)
May 5, 2024, 9:22am
8
@Sathish_Kumar_S
Try this in assign
Dt = dt.AsEnumerable.Where(function(x) arr_Code.Any(function(y) x("CompanyCode").ToString.Contains(y)) AndAlso arr_Code.Any(function(y) x("CompanyCode").ToString.Contains(y))).CopyToDatatable
This would give all matched rows…of if you need to write again each row that if it is matched or not then use below in invoke code
dt.AsEnumerable.ToList.ForEach(sub(x) x("Status") = If(arr_Code.Any(function(y) x("CompanyCode").ToString.Contains(y)) AndAlso arr_Code.Any(function(y) x("CompanyCode").ToString.Contains(y)),"Yes","No"))
Cheers
Thank you for you response during weekend.
Let me explain my requirement again:
There are 2 Data tables DT_CommodityCode & DT_CompanyCode (Attached the files).
Two String array variables ( Arr_Commodity & Arr_Compamycode)
Example Values in Arr_Commodity = {“P000”,“P100”,“P131”} or {“P000”}
Example Value in Arr_CompanyCode = {“3105”,“3112”,} or {“3105”}
Requirement :
Need to validate if any one of the values available in Arr_Commodity variable is available in DT_CommodityCode. If it is matching, then write to str_CommodityStatus = “Yes” else “No”
Need to validate if any one of the values available in Arr_CompanyCode is available in DT_CompanyCode. . if it is matching then write to str_Companycode = “Yes” else “No”
DT_CommodityCode.xlsx (11.2 KB)
CompanyCode.xlsx (9.6 KB)
Anil_G
(Anil Gorthi)
May 5, 2024, 10:51am
10
@Sathish_Kumar_S
Then use the same formula…but remove the and condition and then use each condition separately
Cheers
Sequence.xaml (22.2 KB)
I am not sure if i am following your instruction correctly… Here is the error that i am getting (Please review attached the XAML )
Anil_G
(Anil Gorthi)
May 5, 2024, 11:44am
12
@Sathish_Kumar_S
As per error there are no matching rows…
Also you dont need the assign you need only invoke code for your requirement
Cheers
Got it… but getting the error in invoke code
Anil_G
(Anil Gorthi)
May 5, 2024, 11:51am
14
@Sathish_Kumar_S
Can you please tell the error
Is the new column you need has been added to datatable
Cheers
Error : Invoke Code: Exception has been thrown by the target of an invocation.
I don;t want new column… just want to know if validation is success or not?
Are you able to open the attached XAML file (new_Sequence.xaml)
new_Sequence.xaml (25.4 KB)
Anil_G
(Anil Gorthi)
May 5, 2024, 12:25pm
16
@Sathish_Kumar_S
Dude if new column is not there then how would you know which rows are matching and which are not matchingV?
If you opwn exception details from local you would see the column is missing
Cheers
I have applied below simple logic and my requrement is fullfilled… Shall i use this same logic?
if = arr_commodity.Contains(CurrentRow(“CommodityCode”).ToString())
Anil_G
(Anil Gorthi)
May 5, 2024, 2:57pm
18
@Sathish_Kumar_S
Basically even if one matches you want to know then we can use linq…if you want to check for each row then what you have already done is what you need to do
Cheers