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)

Using RENAME() function in REPEAT until loop

(0) ShareShare
ReportReport
Posted on by 3,967

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,941 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,600 Super User 2025 Season 2 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

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