RENAME - code problem

Navision Articles

Get our Free Newletter

Don't you have the time to be online here at DUG every day? So how do you follow what is going on in the Dynamics industry and community?
If you subscribe to the DUG Newsletter then you can relax! We will make sure that you don't miss the big news!

Check out our
Newsletter Subscription Center
page a complete list of our different newsletters.

Solution (Verified) This post has 1 verified solution | 3 Replies | 1 Follower

Top 100 Contributor
Male
217 Posts
2,765 Points
Joined: Aug 17, 2006
Last Online:
Mar 18, 2010 13:03
Location: Fuengirola, Spain
Colin Bradley posted on Apr 7, 2009 17:47
How helpful was this post/question? Please rate here:

I am trying to change the "No." in the posted sales invoice.


IF InvHead.GET(OldDocNo) THEN
  InvHead.RENAME(OldDocNo,NewDocNo);

I obviously do not understand the example in the Nav help.

I get the error "Too many key fields were specified, so Sales Invoice Header could not be retrieved. The number of fields in the primary key is 1."

Does this mean I am not able to write a non-printing report and change a primary key or is my code rubbish?

Thanks in advance,

Colin

 

"Experience is what you get when you hoped to get money"

Solution (Verified) Verified Solution

Top 10 Contributor
Male
1,103 Posts
25,342 Points
Joined: May 6, 2008
Last Online:
Mar 19, 2010 17:39
Location: Dublin
Moderator
Solution (Verified) DaveT replied on Apr 7, 2009 17:59
How helpful was this comment/solution? Please rate here:
Verified by Colin Bradley

Hi Colin,

The RENAME function work by finding a record and then using the RENAME to insert the new primary key. Each parameter equates to a field on the primary key. In your example it's

InvHead.RENAME(NewDocNo);

Dave Treanor

Dynamics Nav Add-ons
www.simplydynamics.ie/Addons.html

Please:
1. Use a meaningful title.
2. Give as much detail as possible.
3."Verify Solution" to the post that help you solve your problem.
4. Fill out your Tags - it will help other people.
5. N.B. Don't be afraid to ask - we all had to learn and are still learning Wink

All Replies

Top 10 Contributor
Male
1,103 Posts
25,342 Points
Joined: May 6, 2008
Last Online:
Mar 19, 2010 17:39
Location: Dublin
Moderator
Solution (Verified) DaveT replied on Apr 7, 2009 17:59
How helpful was this comment/solution? Please rate here:
Verified by Colin Bradley

Hi Colin,

The RENAME function work by finding a record and then using the RENAME to insert the new primary key. Each parameter equates to a field on the primary key. In your example it's

InvHead.RENAME(NewDocNo);

Dave Treanor

Dynamics Nav Add-ons
www.simplydynamics.ie/Addons.html

Please:
1. Use a meaningful title.
2. Give as much detail as possible.
3."Verify Solution" to the post that help you solve your problem.
4. Fill out your Tags - it will help other people.
5. N.B. Don't be afraid to ask - we all had to learn and are still learning Wink

Top 100 Contributor
Male
217 Posts
2,765 Points
Joined: Aug 17, 2006
Last Online:
Mar 18, 2010 13:03
Location: Fuengirola, Spain
Colin Bradley replied on Apr 7, 2009 18:07
How helpful was this comment/solution? Please rate here:

Thanks...so simple. Wonder why they don't say that in the help text?

 

"Experience is what you get when you hoped to get money"
Top 10 Contributor
Male
1,103 Posts
25,342 Points
Joined: May 6, 2008
Last Online:
Mar 19, 2010 17:39
Location: Dublin
Moderator
DaveT replied on Apr 7, 2009 18:21
How helpful was this comment/solution? Please rate here:

Yes I agree the help in this case is confusing.

Glad to Help Big Smile

Dave Treanor

Dynamics Nav Add-ons
www.simplydynamics.ie/Addons.html

Please:
1. Use a meaningful title.
2. Give as much detail as possible.
3."Verify Solution" to the post that help you solve your problem.
4. Fill out your Tags - it will help other people.
5. N.B. Don't be afraid to ask - we all had to learn and are still learning Wink

Page 1 of 1 (4 items) | Get this RSS feed | Bookmark and Share