Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

operand types are not compatible with the operator

Posted on by Microsoft Employee

Hi everyone,

I occasionaly create job that's why i'm not familiar with this type of error, could you please help me ?

public static void LAF_Update_Sales_Orders(Args _args)
{


SalesTable           SalesTable;
int CPT;

ttsBegin ;

while select forUpdate SalesTable where
                        SalesTable.SettleVoucher == "Open transactions"
                        && SalesTable.Salesstatus == "Open Order"


{
    SalesTable.SettleVoucher = None
    CPT = CPT+1;
}

ttsCommit ;

    info(strfmt("fin du script LAF_Update_Sales_Orders '%1'", CPT));

}



Thanks !

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: operand types are not compatible with the operator

    The final code :

    public static void LAF_Update_Sales_Orders(Args _args)

    {

    SalesTable           SalesTable;

    int CPT;

    ttsBegin ;

    while select forUpdate SalesTable where

                           SalesTable.SettleVoucher == SettlementType::OpenTransact

                           && SalesTable.Salesstatus == SalesStatus::Backorder

    {

       SalesTable.SettleVoucher = SettlementType::None;

       CPT = CPT+1;

    }

    ttsCommit ;

       info(strfmt("fin du script LAF_Update_Sales_Orders '%1'", CPT));

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: operand types are not compatible with the operator

    Thanks a lot !

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: operand types are not compatible with the operator

    If you want to work with SalesStatus field of SalesTable, open the table in AOT and look at the field. You'll see that in this case, it doesn't have any Extended Data Type, but it has Enum Type == SalesStatus. Then you can find this enum type under Data Dictionary > Base Enums in AOT and see which elements it has.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: operand types are not compatible with the operator

    Hi Martin,

    Thanks for your answer, i will pay attention next time.

    One last question, how am i supposed to find the value of the enums SalesStatus::Backorder ?

    Thanks again

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: operand types are not compatible with the operator

    Please don't forget next time to mention which line of code is throwing the error.

    Fortunately I see the bug - it's salesTable.SalesStatus == "Open Order".

    SalesStatus is an enum field and comparing enums with strings isn't allowed. Use an enum value instead:  salesTable.SalesStatus == SalesStatus::Backorder.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans