I need help
I have a list of string and Json with patterns.
Need to get items from list which contains patterns from json
“UK PT 331-1597”,
“FR PT 337-2156”,
“GE ST 338-1608”,
“UK PT 335-2150”,
“UK ST 338-0120”,
“GE PT 338-0203”,
“FR PT 335-2774”,
“GE PT 337-1137”,
“FR ST 333-0296”,
“FR ST 333-0267”
“patterns”: [“335”, “337”]
FR PT 337-2156
UK PT 335-2150
FR PT 335-2774
GE PT 337-1137
Prepared part of the sequence (Requared UiPath.WebApi.Activities):
config.json (38 Bytes)
Tools.xaml (7.3 KB)
How to do it?
Please see the attached .xaml file.
I hope this is the solution you are looking for
Tools.xaml (8.1 KB)
Hi @P2L ,
Since the JArray is containing Array Values, We should be able to convert it to a Array of String type as below :
Then a Small modification to the
selectedTools assign Statement should be able to give you the right output :
Check the Updated Workflow Below :
Tools.xaml (8.9 KB)
Could you also describe your solution in short text or screenshot?
Only attaching a solution file does not provide details to other forum members regarding the approach you used. Doing this will also avoid forum members duplicating the same approach in their posts.
Thank you @Marta and @jeevith. Both of your options suit me and both teach me new things
Yes, of course. Thank you for bringing it into my attention!
The only thing I modified in the original workflow was the Assign activity, which was already developed by the author of the post.
The first idea was:
but it only works for one given number
So I rewrote it to:
(From el In toolNumber Where configJson("patterns").AsEnumerable().Any(Function(x) el.Contains(x.ToString)) Select el).ToList
what this line means is:
take all the elements from toolNumber (
From el In toolNumber [...] Select el )
which match any elements in configJson (
Where configJson("patterns").AsEnumerable().Any(Function(x) el.Contains(x.ToString)) ).
el is an element in
x is an element in configJson. To check the matches I used
.Any method. It determines whether any element of a sequence exists or satisfies a condition. Please see the documentation here:
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.