Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Problem for changing the data in the column

(0) ShareShare
ReportReport
Posted on by 215

Hi everyone,

I had one code problem here. I want try to change the the line section as follow:

i) Line no. with ID 1000 -Description 'Bicycle' change to test777,

ii) Line no.with ID 1120-Description 'spokes' change to test888.

iii)Line no .with ID 1001-quantity '1' change to 10

8883.Capture1.PNG

Here are the code that I had try to scratch out, but the output not been successful as I mentioned above.

Here is the code for change description part:


g_recSalesLine.SETRANGE("Line No.","Line No."); g_recSalesLine.SETRANGE("Document Type","Document Type"); g_recSalesLine.SETRANGE("Document No.","Document No."); IF g_recSalesLine.FINDFIRST THEN BEGIN g_recSalesLine.SETRANGE("Description",'Bicycle','Bicycle'); g_recSalesLine.Description := g_txtDesc; g_recSalesLine.MODIFYALL(Description,'TEST11'); END;


One question for this description part, for example: is it I have to used the Line no. ='1000', then the description will direct change to  test777? And Line No. ='1120', then change to test 888?
Between can somebody tell me how to modify my code above?

Another part is the quantity, below are the code of quantity that I had scratch out:

g_recSalesLine.SETRANGE(Quantity,Quantity);

IF g_recSalesLine.FINDFIRST THEN BEGIN
   g_recSalesLine.Quantity := g_decQty;
   g_recSalesLine.MODIFY;

END;

If I used the code of quantity, it will direct change all 3 lines of quantity to '10',but not only Line No. ='1001'(I only want to change the quantity to 10 with Line No. ='1001'. 

Hope anyone can help me out for the problem above.

Many thanks here.

*This post is locked for comments

  • Verified answer
    TeddyH Profile Picture
    TeddyH 12,868 Super User 2024 Season 1 on at
    RE: Problem for changing the data in the column

    Are you filtering Line No or No ? Those are two different fields.

    I will give you one example based on what you are trying to do.

    g_recSalesLine.SETRANGE("Document Type","Document Type");

    g_recSalesLine.SETRANGE("Document No.","Document No.");

    g_recSalesLine.SETRANGE(Type,g_recSalesLine.Type::Item);

    g_recSalesLine.SETRANGE("No.",'1000');

    IF g_recSalesLine.FINDFIRST THEN BEGIN

      g_recSalesLine."Description" := 'TEST777';  

      g_recSalesLine.MODIFY(TRUE);

    END;

    You are not supposed to filter the filter where you want to modify. If you want to do this, use two variables.

    g_recSalesLine.SETRANGE(Quantity,Quantity);

    IF g_recSalesLine.FINDFIRST THEN BEGIN

      g_recSalesLine2 := g_recSalesLine;

      g_recSalesLine2.VALIDATE(Quantity,g_decQty);

      g_recSalesLine2.MODIFY(TRUE);

    END;

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

News and Announcements

Announcing Category Subscriptions!

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans