Problem in updating Sales Invoice Header table through code

mkpjsr
Member Posts: 587
Hi all,
While posting Sales Credit memo I am trying to update the Reason Code field of "Sales Invoice Header" table through code,but its not getting updated and the same is happening with partner license. Is there any way to do this without partner license.
While posting Sales Credit memo I am trying to update the Reason Code field of "Sales Invoice Header" table through code,but its not getting updated and the same is happening with partner license. Is there any way to do this without partner license.
0
Comments
-
a credit memo moves to the "Sales Cr.Memo Header" so are you saying you are applying the cm to a posted sales invoice and you want the applied invoice to be updated?
what's your code?0 -
Savatage wrote:a credit memo moves to the "Sales Cr.Memo Header" so are you saying you are applying the cm to a posted sales invoice and you want the applied invoice to be updated?
what's your code?
i have written the following code:
IF SalesInvHeader.GET("Applies-to Doc. No.") THEN BEGIN
SalesInvHeader."Reason Code":=Rec."Reason Code";
SalesInvHeader.MODIFY;
END ELSE BEGIN
MESSAGE('Invoice No. not Found');
END;0 -
I'll assume you have the code on the OnAfterValidate of the "Applies-To Doc. No."
I've added the message field so you can see when the value exists.
If you try it again you'll see if you use the lookup to get the Invoice number- your code doesn't work.
But if you copy the invoice number and paste it into the "Applies-To Doc. No." it will!
the lookup is not triggering the OnAfterValidate.
OnAfterValidate()
IF SalesInvHeader.GET("Applies-to Doc. No.") THEN BEGIN
SalesInvHeader."Reason Code":= "Reason Code";
MESSAGE('%1',"Applies-to Doc. No.");
SalesInvHeader.MODIFY;
END ELSE BEGIN
MESSAGE('Invoice No. not Found');
END;
But with a regular customer license you should then get an error saying you're not allowed to modify the Sales Invoice Header Table. Then (for me) I would then have to edit CU391 to allow me to change that field.0 -
Are you a partner or a customer?
SalesInvoiceHeaderEdit(SalesInvoiceHeader : Record "Sales Invoice Header")SalesInvoiceHeader2 := SalesInvoiceHeader;
SalesInvoiceHeader2.LOCKTABLE;
SalesInvoiceHeader2.FIND;
SalesInvoiceHeader2."Reason Code" := SalesInvoiceHeader."Reason Code";
SalesInvoiceHeader2.MODIFY;
SalesInvoiceHeader := SalesInvoiceHeader2;
I know this makes the field editable but not sure if updating it thru code from another form will work. Testing is needed & your partner should help.
I'm guessing it should still crash on -> SalesInvHeader.MODIFY;
Ever thought about using the Credit & order Comments?0
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