Dynamics 365 Business Central 2023 wave 1 (BC22) is generally available last week. More details: Dynamics 365 Business Central 2023 release wave 1 (BC22)
I will continue to test and share some new features that I hope will be helpful.
Iterating with foreach on Text variables:
Sometimes you need to loop through text strings—for example, to identify characters, remove, or replace them. With this release we are adding support for using the foreach operation on Text variables, making it easier to perform this iteration.
MS Learn (Docs) has also been updated.
Foreach control structure:
Yes, with this wave (BC22), you can now use the existing foreach loop operation on Text variables, allowing you to detect as well as remove or replace individual characters in strings.
Let’s look at a very simple example: We can use the following method to count how many A are in the string in a very simple way.
PS: In previous versions
A ‘foreach’ statement can only be used with an expression of an enumerable type.
Another example, we have discussed how to prevent users from entering special characters inside an input field before. In this post, I introduced two ways.
Now we can use foreach processing.
Very nice, give it a try!!!😁
Hope this will help.
Thanks for reading.