web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Using RENAME() function in REPEAT until loop

(0) ShareShare
ReportReport
Posted on by 4,009

Hi,
I've a requirement to modify a paticular field in which is primary key. It works for other tables but when I'm using RENAME statement in REPEAT UNTIL gives the error 'the number of field arguments does not match the primary key size'

Code:

//Change Driver in Amortization Lines
CF_AmortizationLinesTable.RESET;
CF_AmortizationLinesTable.SETRANGE("Contract No",CF_ContractsNo);
IF CF_AmortizationLinesTable.FINDFIRST THEN BEGIN
REPEAT
CF_AmortizationLinesTable.RENAME(CF_AmortizationLinesTable."Leased to Driver No.",DriverNo);
UNTIL CF_AmortizationLinesTable.NEXT = 0;
MESSAGE('AL');
END
ELSE
ERROR('Create Amortization Schedule prior assuming the Lease Driver!!');

Note: CF_AmortizationLines Table has 3 keys No., Line No, Leased to Driver No.. 
Kindly suggest.

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    In RENAME you need to pass the new key values, so if the CF_AmortizationLines Table key is composed of 3 fields, you need to pass 3 values with the appropriate type.

    Here, I see that you're using only two fields:

    CF_AmortizationLinesTable.RENAME(CF_AmortizationLinesTable."Leased to Driver No.",DriverNo);

  • Verified answer
    Andrey Baludin Profile Picture
    3,943 on at

    When you use RENAME - you have to set all parts of a table key. So in your case it'll be next:

    CF_AmortizationLinesTable.RENAME(CF_AmortizationLinesTable."No.", CF_AmortizationLinesTable."Line No", DriverNo);

  • Suggested answer
    RockwithNav Profile Picture
    8,959 Super User 2026 Season 1 on at

    In a nutshell I have to say, I will say like renaming a primary key is not recommended until and unless its deadly required, Even for a single record it takes a way more time if it's a standard table, so if you are using in Repeat Until then can think of what can be happening as system goes extremely busy.

    But still if you have to then you need to check the combination of Primary key and then use Rename function for all those combinations in Rename Parameter respectively.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans