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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

X++ query cannot recognize local variable value ?

(0) ShareShare
ReportReport
Posted on by 558

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

  • Verified answer
    GirishS Profile Picture
    27,845 Moderator on at

    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.

  • Mohit Rampal Profile Picture
    12,573 Moderator on at

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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 264 Super User 2026 Season 2

#2
Aayush Tiwari Profile Picture

Aayush Tiwari 219

#3
Subra Profile Picture

Subra 164 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans