Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

remove the last comma from the message

Posted on by 425

Hi all, 

 this is my job 

static void Job218(Args _args)
{
    SalesTable SalesTable;
    str message;

    while select SalesTable  where SalesTable.SalesStatus == SalesStatus::Delivered
    {
        message = message + strFmt("%1,",SalesTable.SalesId);
    }

    print(message);
    pause;
}

here in the output   in message i am getting an extra comma which i want to remove  so that my message looks like

message = "a,b,c,d" not like "a,b,c,d,"(the extra comma after d in the message )

*This post is locked for comments

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: remove the last comma from the message

    I think it's better if you don't insert the last comma in the first place. Do it like this:

    static void Job218(Args _args)
    {
        SalesTable SalesTable;
        str message;
        boolean firstLine = true;
    
        while select SalesTable  where SalesTable.SalesStatus == SalesStatus::Delivered
        {
    
            if (firstLine)
            {
                message = strFmt(%1",SalesTable.SalesId);
                firstLine = false;
            }    
            else
            {
                message = message + strFmt(", %1",SalesTable.SalesId);
            }
    
        }
    
        print(message);
        pause;
    }


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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans