Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Correct placement of modify

Posted on by Microsoft Employee


Expected Receipt Date - OnValidate() countLines:= 0; Item.SETRANGE("No.",Rec."No."); Item.SETRANGE("Location Filter",Rec."Location Code"); Item.FINDFIRST; Item.CALCFIELDS(Inventory); SalesOrderLine.SETRANGE("No.",Item."No."); SalesOrderLine.SETRANGE("Document Type",SalesOrderLine."Document Type"::Order); SalesOrderLine.SETRANGE(Type,SalesOrderLine.Type::Item); SalesOrderLine.SETRANGE("Location Code",Rec."Location Code"); SalesOrderLine.SETFILTER("Outstanding Quantity",'>=0'); SalesOrderLine.SETCURRENTKEY("Document Type",Type,"No.","Variant Code","Drop Shipment","Location Code","Shipment Date"); SalesOrderLine.ASCENDING(TRUE); IF SalesOrderLine.FIND('-') THEN BEGIN REPEAT SalesOrderLine."Shipment Date" := Rec."Expected Receipt Date" +1; SalesOrderLine.MODIFY; countLines += 1; UNTIL SalesOrderLine.NEXT = 0; END; MESSAGE(FORMAT(countLines));

This is my code for page 54 Purchase Order Subform, I want to change the date with the filters above.

When I have the code where it changes the date and the modify - It only changes 1 record.

If i comment those 2 lines out, the counter will message out 4 - which is the correct.

          SalesOrderLine."Shipment Date" := Rec."Expected Receipt Date" +1;
          SalesOrderLine.MODIFY;

*This post is locked for comments

  • Suggested answer
    RE: Correct placement of modify

    Hi,

    Also if you want to keep the SETCURRENTKEY, then you can moving it up before the SETRANGE.

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Correct placement of modify

    Remove the setcurrentkey and ascending code lines and try again.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans