I am looking for a way to remove any non 10-digit values from an array. In this example I was to remove the 123@domain.com value but keep the 5551112222 values.
Here is the array:
I am looking for a way to remove any non 10-digit values from an array. In this example I was to remove the 123@domain.com value but keep the 5551112222 values.
Here is the array:
You can use the following expression to get the length of items from an array (including Filter array).
length(body('Filter_array'))
In the example below, if you only wanted to do something if the array contained at least one item (length is greater than zero) you would put all your actions within the Yes branch.
Hello,
Thank you for your repsonce. Would you be able to provide me an example of how to check for the length was greater then zero please?
If you ended up with no results after the filter, you could check the length of the Filter array and only continue if the length was greater than zero.
Thank you. I did find the use case where the 123@domain.com was the only result and was filtered out causing the flow to think it was an error. To me this is fine but what is the best way to handle?
Thank you. I did find the use case where the 123@domain.com was the only result and was filtered out causing the flow to think it was an error. To me this is fine but what is the best way to handle?
When you say you want to remove the value - do you want to just remove the value from that particular object, or remove the entire object if it contains non-10-digit values?
If you meant filter the array so only objects that contain a 10-digit value would remain, then you could do something similar to below.
Compose contains your array of objects.
Filter array uses the output from the Compose and applies the following filter.
//Checks that the length of value is equal to 10, and
//Checks that value is a valid float (number)
@and(
equals(length(string(item()?['value'])), 10),
equals(isFloat(item()?['value']), true)
)
After running the flow, we would have the following output (excludes the object with invalid value).
[
{
"waitTime": 0,
"status": "A",
"pathId": 2419001148045324,
"countryCode": "US",
"value": "5551112222",
"skipValidation": false,
"pathEnable": true
},
{
"waitTime": 0,
"status": "A",
"pathId": 2419001148045319,
"countryCode": "US",
"value": "5551112222",
"skipValidation": false,
"pathEnable": true
}
]
----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
What is the previous and What is your next step? I assume you want to use the array values in something that would likely put it in a apply to each. If so the field can be be set to null to remove teh email.
WarrenBelz
146,668
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,004
Most Valuable Professional