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 NAV (Archived)

Replace the code

(0) ShareShare
ReportReport
Posted on by 4,824

Hi experts, we want to replace the salesperson code A with new code B for the customer table. How to accomplish it in report? Thank you!

Customer.SETRANGE("salesperson code.","salesperson code.");

IF Customer.FIND THEN

...

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Try following code.

    Customer.Reset;

    Customer.SETRANGE("salesperson code.","salesperson code.");

    IF Customer.FINDSET THEN

    Repeat

     Customer.Validate("Sales Person Code","New Salesperson Code");

      Customer.Modify;

    Until Customer.Next = 0;

    Hope this helps.

  • Verified answer
    4BzSoftware Profile Picture
    6,073 on at

    Hi Snoppy and Vishal,

    I think you should declare and use a Customer record variable (lRec_CustomerUpdate) in "Customer - OnAfterGetRecord()" trigger of Customer Report DataItem, write below code in "Customer - OnAfterGetRecord()" trigger:

    IF (lRec_CustomerUpdate.GET("No.")) THEN BEGIN

      lRec_CustomerUpdate.VALIDATE("Salesperson Code", New Code B);

      lRec_CustomerUpdate.MODIFY(TRUE);

    END;

    Remember to force filter on Salesperson Code of Customer Report DataItem (prevent updating all customers). Besides, it is more flexible if user can select New Salesperson Code in Request Page instead of hard code New Code B.

  • Suggested answer
    RockwithNav Profile Picture
    8,635 Super User 2025 Season 2 on at

    Hey snoppy,

    If you really want to achieve this via Report then I believe you should go with what Khoa Nguyen suggested as its a more ideal solution, If you want to do it via some code-unit then you can go with what Vishal suggested except keeping MODIFY(TRUE)  ;

  • Community Member Profile Picture
    on at

    You can even write this code in report - OnPreReport() trigger without adding any dataitem :).

    Yes, MODIFY(TRUE) would help you have Contact defined against Customer, else MODIFY would work fine.

  • snoppy Profile Picture
    4,824 on at

    Thank you experts!

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    One other solution without developing is to use Rapid Start Services to replace the values, Please check the below link for more information

    www.dynamicsnavconsultant.com/.../find-and-replace-data-in-dynamics-nav-2016-with-rapidstart

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 NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans