Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Using RENAME() function in REPEAT until loop

Posted on by 3,957

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

  • Verified answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: Using RENAME() function in REPEAT until loop

    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.

  • Verified answer
    Andrey Baludin Profile Picture
    Andrey Baludin 3,941 on at
    RE: Using RENAME() function in REPEAT until loop

    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
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Using RENAME() function in REPEAT until loop

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans