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)

[AX 2012 R3] Runtime Error in WHERE-clause "Parameter is incorrect"

(0) ShareShare
ReportReport
Posted on by

Hi everyone,

i run into a runtime error with the following WHERE-clause. Do you have any idea how to solve this? Aim is to get all the orders that are older than "expirationDays".

It works if i shift the red marked condition into the loop but thats very ineffective i think.

5488.pic1.png

Regards

Nils

*This post is locked for comments

I have the same question (0)
  • Verified answer
    André Arnaud de Calavon Profile Picture
    301,075 Super User 2025 Season 2 on at

    Hi Nils,

    You can't use the today()- transferTable.Shipdate.

    You can create a new variable called e.g. dueDate and calulate a date based on today() and expiration days. Then you can do a where clause comparing the Shipdate with the dueDate.

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    if nothing works as calculated field, last approach can be to replace line of where clause with If condition inside {  }

    Of course seems a stupid approach, but needed sometimes in AX.

  • Community Member Profile Picture
    on at

    Hi Andre,

    thank you...works like a charm.

    public void adjustExpiredTransferOrders(KVHandleUnsatisfiedOrdersDataContract _dataContract)
    {
        InventTransferTable     transferTable;
        InventTransferLine      transferLine;
        WHSInventTransferLine   whsTransferLine;
        date                    dueDate;
        
        dueDate = today() - _dataContract.parmExpirationDays();
        
        ttsBegin;
    
        while select * from transferTable
            where transferTable.ShipDate < dueDate &&
                transferTable.TransferStatus == InventTransferStatus::Created
            join forUpdate * from  transferLine
                where transferLine.TransferId == transferTable.TransferId
            join whsTransferLine
                where whsTransferLine.InventTransferLine == transferLine.RecId &&
                    whsTransferLine.ReleasedQty < transferLine.QtyRemainShip &&
                    whsTransferLine.OnWave == NoYes::No
        {
            transferLine.QtyRemainShip = 0.0;
            transferLine.updateDeliverRemainder();
        }
    
        ttsCommit;
    }


    Regards Nils

  • Jesus R. ABASCAL Profile Picture
    1,450 on at

    I aggree with Sohaib you should verify it with if condition.

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    Jesús R. Abascal ,

    if condition only needed when we are out of all options for creating a query and joins are very complex

  • Community Member Profile Picture
    on at

    Thanks for your efforts. I think Andre's approach is the most elegant.

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    Nils Kuttkat,

    yes I agree with 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