Split a string into a container in Microsoft Dynamics 365
Some times
when developing we encounter some strings of which we only need a segment of
the string, let’s say for example the addresses on AX that are formed by
several lines.
So When
you run in the need to separate a String in several parts, you can use the
method that we are creating in this post, this function will take 3 parameters:
- String
- Delimiter
- Index
This
methods will require some variable to be declared previously:
Declare
Variables:
List _list = new List(Types::String);
container con;
ListIterator iterator;
str String;
;
String = "Raji-Jones-Leena-Mangomani";
_list = Global::strSplit(String,"-");
iterator =new ListIterator(_list);
while (iterator.more())
{
con += iterator.value();
iterator.next();
}
Now we have a
populated container and, using the
“conPeek” standard function we can retrieve the elements from the container by
the index.
info(conPeek(con,conLen(con)));// i want to print last value of container so i use conLen(con)
output:
Comments
Post a Comment