Skip to main content

Notifications

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

While select statement in X++

Posted on by 157
Hi Team
 
Below code i am writing to achieve my requirement.
Here if custPackingSlipTransView.DlvTerm don't have the data then also loop is going inside the while.
  while select custPackingSlipTransView order by SalesId desc                where custPackingSlipTransView.OrderAccount == salesTable.CustAccount                  && custPackingSlipTransView.DeliveryDate == deliveryDate                  && custPackingSlipTransView.Qty > 0.00                notexists join salesLine where custPackingSlipTransView.InventTransId == salesLine.InventTransIdReturn                exists join dlvTerm where custPackingSlipTransView.DlvTerm == dlvTerm.Code                  && dlvTerm.DlVstatus == NoYes::Yes
 
If i remove below join from above condition in that case loop is going inside the while, if table data has match with the condition.
  exists join dlvTerm where custPackingSlipTransView.DlvTerm == dlvTerm.Code                  && dlvTerm.DlVstatus == NoYes::Yes
 
Please let me know how to add above join with while select statement, if custPackingSlipTransView.DlvTerm == dlvTerm.Code have data then only loop should go inside the while else not.
  • Verified answer
    GirishS Profile Picture
    GirishS 27,832 Super User 2024 Season 1 on at
    While select statement in X++
    Hi,
     
    Try adding the not exist join as the last join in the while select statement.
     
    while select custPackingSlipTransView order by SalesId desc                
    where custPackingSlipTransView.OrderAccount == salesTable.CustAccount                  
    && custPackingSlipTransView.DeliveryDate == deliveryDate                  
    && custPackingSlipTransView.Qty > 0.00
    exists join dlvTerm where custPackingSlipTransView.DlvTerm == dlvTerm.Code                  
    && dlvTerm.DlVstatus == NoYes::Yes                
    notexists join salesLine 
    where custPackingSlipTransView.InventTransId == salesLine.InventTransIdReturn                
    
     
    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

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

Product updates

Dynamics 365 release plans