Create dynamics NAV error message when sales amount is 0

NavNewbie92
Member Posts: 3
Hi everyone , I'm relatively new to NAVISION world , I have a question i will be very grateful if someone can help me.
I have to create an error message that block a user when he tries to validate an sales invoice with 0 amount.
I'm sure I will be use an IF with Error msg like this :
SalesHeader.SetRange("No.", "Document No")
SalesHeader.Find('-')
If SalesHeader.Amount=0
then begin
Error('The Amount of the relate order "No.":=' +SalesHeader."No."+' cannot be 0.')
but I don't know where I will put that is on a code unit or on the order page ?
thanks for your help.
Kind regards
I have to create an error message that block a user when he tries to validate an sales invoice with 0 amount.
I'm sure I will be use an IF with Error msg like this :
SalesHeader.SetRange("No.", "Document No")
SalesHeader.Find('-')
If SalesHeader.Amount=0
then begin
Error('The Amount of the relate order "No.":=' +SalesHeader."No."+' cannot be 0.')
but I don't know where I will put that is on a code unit or on the order page ?
thanks for your help.
Kind regards
0
Answers
-
Hello, In the trigger of the validation of the sales invoice, put this code to see if it works ... I hope so.
IF "Amount Including VAT" = 0 THEN
BEGIN
ERROR('Error Message Text');
END
ELSE BEGIN
EXIT;
END;
0 -
Hello @NavNewbie92. Can you tell me which version are you using of NAV?
Also whichever version you are using after 2013R2 till 2016 you have the below option
1) There is a post button on the Sales Order Page, you can write this code there before the program goes into the Sales-Post Codeunit. This will not allow the user to post the document until they bypass your error statement. Hope so i was clear in explaining you the answer in short.
If you are using NAV 2016 and above you have 2 options
1) Same as option 1
2) You can create a code unit, create a function inside the code unit which will be a "Subscriber" function (Since you are a new bie, i am not completely sure if you know about Subscriber Functions, if not please search it once on the web, they are the way forward). In this subscriber function you will set the property of this function to trigger when the "OnBeforePost" Publisher is hit.~~ Jack of all, Master of NAV! ~~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