Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

X++ query cannot recognize local variable value ?

(0) ShareShare
ReportReport
Posted on by 516

Hi guys,

Just for learning and understanding purpose, when we create query using X++, the usual "while select..." sometime using join table, but if in one of the WHERE condition I'm using a local variable, does it not count ?

I experienced like this scenario:

I have variable Balance and in my query specified something like "while select..... where balance > 0", then realized when balance is 0 the process will still come inside While. I have to put another if condition inside the while statement like:

If (!balance)

       continue;

to make it to just skip the rest command inside and next loop.

Thanks

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: X++ query cannot recognize local variable value ?

    In addition, Its better to check value of variable before the code of while loop.

  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: X++ query cannot recognize local variable value ?

    Hi ken,

    You cannot add a variables in the while select or select statement. You need to check that separately in the if condition.

    Thanks,

    Girish S.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans