web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

how to breaking a string that concatenated using #newline

(0) ShareShare
ReportReport
Posted on by

I have a string was concatenated using #newline. It looks  like following:

originalString= SerialNumber1 + #newline + SerialNumber2 + #newline + SerialNumber3 + #newline + SerialNumber4 +...+....

I need to get individual Serial Number from the originalString.

 

Note: the length of individual serial number is NOT same.


The problem is  I don't know what exactly characters that defined in Macro #newline. I tried to debug still not display the characters. Otherwise I can use strScan function to get the position of the #newline. Then do a loop to get individual serial number.

 

Any advice would be appreciated

Anna

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    You can try next code:

    container c = str2con(originalString, #newline);

    It will create a container where each element will be a serial number.

    Then you can iterate through container using for loop to get individual elements.

    Also you can look for #define.newline() in the top of you method\ class declaration to see what what characters are used or it could be included into macro library, but this library should be used in the top of the method \ class declaration as well (#macroLibraryName). 

  • Verified answer
    Hajish Profile Picture
    460 on at

      check the below code may help to you.

       List                            list = new List(Types::String);

       container                  packedList;

       ListIterator                iterator;

       str                             originalString ,result;

       ;

               originalString= SerialNumber1 + #newline + SerialNumber2 + #newline + SerialNumber3 .... ;

               list = strSplit(originalString , "\n");

               iterator = new ListIterator(list);

               while(iterator.more())

               {

                   packedList += iterator.value();

                   iterator.next();

               }

               // "SerialNumber1" is stong to result.

               //result= conPeek(packedList, 1);

  • Community Member Profile Picture
    on at

    Thank you Hajish and Ievgen ! That's really helpful.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans