Question about updating a record in ProcessOnlyReport

fabrizioc
Member Posts: 31
Hi to all, I'm writing a ProcessOnlyReport, in OnAfterGetRecord I want to update a value adding a trailing A character to a record in a field that is the primary key.
If I use the MODIFY statement I got an error because I cannot modify the primary key of the record.
Looking at forum it seems that I have to delete the exisiting record and insert a new one (????). Is it correct ? Can someone suggest me the best practice to do this kind of operation?
My Table is called SalesDocument and has a primary key field called Document No.
I've tried the following code
SalesDocument.GET("Document No.");
SalesDocument.RENAME("Document No." + 'A');
but it fails to retrieve the document.
Can someone help me?
Thank you in advance for your help.
Best regards
Fabrizio
If I use the MODIFY statement I got an error because I cannot modify the primary key of the record.
Looking at forum it seems that I have to delete the exisiting record and insert a new one (????). Is it correct ? Can someone suggest me the best practice to do this kind of operation?
My Table is called SalesDocument and has a primary key field called Document No.
I've tried the following code
SalesDocument.GET("Document No.");
SalesDocument.RENAME("Document No." + 'A');
but it fails to retrieve the document.
Can someone help me?
Thank you in advance for your help.
Best regards
Fabrizio
0
Answers
-
Hi, the rename should usually work like you did it.
If your dataitem (of which you use onaftergetrecord) also loops the SalesDocument table it wont work though.
I'd also try saving the new key beforehand instead of adding to the old one
saveKey := "document no." + 'A';
RENAME(saveKey)
Austrian NAV/BC Dev0 -
Hi,
Yes what Waisa Said is true.
Just to add to that -
> Modify works when you change anything in the Record Except Primary Key.
> For Changing Fields which are part of Primary key use Rename.
Thanks & Regards,
Saurav Dhyani
Do you Know this About NAV?
Connect - Twitter | Facebook | Google + | YouTube
Follow - Blog | Facebook Page | Google + Page0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions