Split a string into a container in Microsoft Dynamics AX

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:


Since we are running this in a Job we are going to manually set the string


we will initialize the list using the standard method strSplit of Dynamics AX, we will use as the separator the “-” character without quotes.


Now we must start the iterator for our list.


The iterator will loop through the lines of our list and them to a container which in our example will be “packedList”.


Now we have a populated container and,  using the “conPeek” standard function we can retrieve the elements from the container by the index.


We will call to the second segment of the string that we created before (“Smith”), and as expected we got just that as we can see below.


So again let’s try with another index, this will we will set the value to 1 like this:


And as expected we got the first segment of our string.


  • Andesoft International

    by LP

  • Andres Tellez

    What if i want to split the word “Jhon”? i want the container to be

    • Itsuki Minami

      Well using this method you need to have a character that will separate the words, I will try and see if what you need is possible, and make another blog post.

      • Andres Tellez

        I already solved it. I couldn’t use str split method. i just use substr and then save every character in a container. It works.

  • Thoughts_Of_A_Simple_Fellow

    you might want to consider str2con function.
    packedList = str2Con(Cadena, “-“);