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

  • Suggested answer
    Suresh Kulla Profile Picture
    47,789 on at
    RE: Replace the code

    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

  • snoppy Profile Picture
    4,824 on at
    RE: Replace the code

    Thank you experts!

  • Community Member Profile Picture
    on at
    RE: Replace the code

    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.

  • Suggested answer
    RockwithNav Profile Picture
    6,784 on at
    RE: Replace the code

    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)  ;

  • Verified answer
    4BzSoftware Profile Picture
    6,073 on at
    RE: Replace the code

    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.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Replace the code

    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.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans