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)

CHANGING CUSTOMER NUMBER ON CUSTOMER TABLE

(0) ShareShare
ReportReport
Posted on by

Hello I am using a report to effect the change of customer number often.

For Example;

OldCustomerNumber to be 'xx'

NewCustomerNo to Be 'yy'

However am getting an error: Customer Does not Exist. Identification Fields and Values: No.='yy'

The error is popping up when the Modify function is triggered under modify customer number section. The same code is working out perfectly for all other customer related tables.

Anyone with a better idea of doing this?

Here is the code,

  Customer - OnAfterGetRecord()
  Customer."Old Customer Code":=Customer."No.";
  Customer.MODIFY;

  OldCustomerNo:=Customer."Old Customer Code";
  NewCustomerNo:=Customer."New Customer No";

  //Modify Customer No:
  Cust.SETCURRENTKEY(Cust."Old Customer No");
  Cust.GET(OldCustomerNo);
  Cust.VALIDATE(Cust."No.",NewCustomerNo);
  Cust.MODIFY;

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    you should uses RENAME while changing the primary key

  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    msdn.microsoft.com/.../dd355313.aspx

  • Community Member Profile Picture
    on at

    Hello, Whether I Use Rename or Modify am getting the same error.

  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    is it your complete code?

    can you change this line to

    Cust.GET(OldCustomerNo); // OLD code

    IF Cust.GET(OldCustomerNo) THEN //NEW code

    // RENAME Code here

  • Community Member Profile Picture
    on at

    am now getting a new error:The number of field argument does not reach the primary key size.

  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    can you show your full new code

  • Community Member Profile Picture
    on at

    I have Only changed this bit

    //Modify Customer No:

    Cust.GET(OldCustomerNo);

    IF Cust.GET(OldCustomerNo) THEN

    Cust.RENAME(Cust."No.",NewCustomerNo);

  • Verified answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    it should be

    IF Cust.GET(OldCustomerNo) THEN

     Cust.RENAME(NewCustomerNo);

    only

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