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)

Is it Possible to manipulate the braces " < > " from the List.Tostring() Output

(0) ShareShare
ReportReport
Posted on by 353

Hi - 

   I have a list of type String. It is storing all the values from DocuRef.Notes field through a while select statement.  The list is populated just fine with all the possible records but the problem is when I'm printing the list on my report though a display method and List.Tostring(). The records are printed with these braces in the start. look at the picture below. 

2017_2D00_02_2D00_22.png

I dont need those braces in the begining and at the end of my first line. 

The output should be like 

Test Line 1 

Test Line 2 

.... 

Both Records should be printed on separate lines. Can you suggest if I can achieve this through list ? or I have to use some other way? Like what ? Thank You 

Here is the snippet of my code. 

display String255 WFdisplayCustomerNotes()
{
    // <WF - ID = 80  Picking Slip (123) modified by Unomani>
    SalesTable        salesTable;
    Notes             notes;
    WHSWorkLine       whsWorkline;
    DocuRef           docuRef;
    CustTable         custTable;
    Counter           counter = 0;
    List NotesList = new List (Types::String);
    
    select OrderNum
        from whsWorkline
          join * from salesTable
            where this.OrderNum == salesTable.SalesId;

    while select * from docuRef
        join * from custTable
             where docuref.RefTableId == 77 
                   && custTable.AccountNum == salesTable.CustAccount
    {
            if ( docuRef.TypeId == 'Shipping Instruction' 
                && docuRef.RefRecId == custTable.RecId 
                && docuRef.RefTableId   == custTable.TableId 
                && docuRef.RefCompanyId == custTable.dataAreaId 
                && salesTable.CustAccount == custTable.AccountNum)
            {    
                notes = docuRef.Notes;
                NotesList.addEnd(notes);  
            }  
    }           
    return NotesList.toString();     
}
//</WF>

*This post is locked for comments

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

    Instead of using list.tostring() you can use listenumerator to enumerate through elements in a list and output values in a way you want msdn.microsoft.com/.../aa642991(v=ax.50).aspx

  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    Instead of using list.tostring() you can use listenumerator to enumerate through elements in a list and output values in a way you want [View:https://msdn.microsoft.com/en-us/library/aa642991(v=ax.50).aspx]

  • Muhammad_Ali Profile Picture
    353 on at

    Hello ievgen -

     If im not wrong list enumerator will allow me to return the records from the list separately ?

    I will try this approach and let you know if it worked.

    Thanks

  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    ListEnumerator allow you to get individual element from a list, then you can concatenate them into a string or do something else. Please try and let us know in case of any issues.

  • Verified answer
    Muhammad_Ali Profile Picture
    353 on at

    ievgen thank you for your help this approach worked. Instead of list enumerator I used List iterator. look at the code snap below

    display str WFdisplayCustomerNotes()

    {

    // <WF - ID = 80 Picking Slip (123) modified by Unomani>

       SalesTable        salesTable;
    
       Notes             notes;
    
       WHSWorkLine       whsWorkline;
    
       DocuRef           docuRef;
    
       CustTable         custTable;
    
       container         packedList;
    
       int i;
    
       ListIterator    iterator;
    
       Str       result;
    
       List NotesList = new List (Types::String);
    
       if (NotesList)
    
       {
    
           select OrderNum
    
               from whsWorkline
    
                 join * from salesTable
    
                   where whsWorkline.OrderNum == 'SON-0000376'
    
                   && whsWorkline.OrderNum == salesTable.SalesId;
    
           while select * from docuRef
    
               join * from custTable
    
                    where docuref.RefTableId == 77
    
                          && custTable.AccountNum == salesTable.CustAccount
    
           {
    
               if (docuRef.TypeId == 'Shipping Instruction'
    
                   && docuRef.RefRecId == custTable.RecId
    
                   && docuRef.RefTableId   == custTable.TableId
    
                   && docuRef.RefCompanyId == custTable.dataAreaId
    
                   && salesTable.CustAccount == custTable.AccountNum)
    
               {
    
                   notes = docuRef.Notes;
    
                   NotesList.addEnd(notes);
    
               }
    
           }
    
       }
    
           iterator = new ListIterator(NotesList);
    
           while (iterator.more())
    
           {
    
               packedList += iterator.value();
    
               iterator.next();
    
           }
    
           for (i = 1 ; i <=conLen(packedList); i++)
    
           {
    
               if (result == "")
    
               {    
    
                  result   = conpeek(packedList,i);
    
               }
    
               else    
    
               {    
    
                  result = result + '\n' + conpeek(packedList,i) ;
    
               }
    
           }
    
       return result;
    
    }
  • Mea_ Profile Picture
    60,284 on at

    Hi Muhammad_Ali,

    Why do you need to add value to container, you can just create string and avoid extra loop\code. If it's just an example and you need container because of some reason there is smarter way to convert container to string, please take a look at con2str() method. In you case it would be something like result  = con2str(packedList, '\n');

  • Muhammad_Ali Profile Picture
    353 on at

    hmm interesting let me look into it ievgen. I do need to use a container because I'm using a container to get the values into string Result. I was having issues doing the same with a list because of the way list output has those automated braces "<>".

    Thank You

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