on post of purchase order how to show error msg if field is empty?

mdsr
Member Posts: 163
Hi all,
I am trying to add error mssage if any field in purchase order is empty while posting.for that i have added a code on Post action as
how i can wtite code so that it will work properly
thanks in advance.
I am trying to add error mssage if any field in purchase order is empty while posting.for that i have added a code on Post action as
IF "Buy-from Vendor No."='' THEN BEGIN ERROR('Error:Empty field'+FIELDCAPTION("Buy-from Vendor No.")+'Please Add Data in field.'); END; IF "Buy-from Vendor Name"='' THEN BEGIN ERROR('Error:Empty field '+FIELDCAPTION("Buy-from Vendor Name")+'Please Add Data in field.'); END; IF "Buy-from Contact No."='' THEN BEGIN ERROR('Error:Empty field '+FIELDCAPTION("Buy-from Contact No.")+'Please Add Data in field.'); END; IF "Buy-from City"='' THEN BEGIN ERROR('Error:Empty field '+FIELDCAPTION("Buy-from City")+'Please Insert Data in field.'); END; IF Structure='' THEN BEGIN ERROR('Error:Empty field '+FIELDCAPTION(Structure)+'Please Insert Data in field.'); END; IF "PO Type"="PO Type"::" " THEN BEGIN ERROR('Error:Empty field '+FIELDCAPTION("PO Type")+'Please Insert Data in field.'); END;for line level of Purchase order code like this
[code]RecPurchLine.RESET; RecPurchLine.SETRANGE(RecPurchLine."Document No.","No."); //RecPurcaseLinehLine.SETRANGE(RecPurchLine."Document Type","Document Type"); IF RecPurcaseLine.FIND('-') THEN BEGIN //REPEAT IF RecPurchLine.Type=RecPurchLine.Type::" " THEN BEGIN MESSAGE('Error:Empty field Type Please Insert Data in field.'); END; IF RecPurchLine."No."='' THEN BEGIN MESSAGE('Error:Empty field '+FIELDCAPTION("No.")+'Please Insert Data in field.'); END; //UNTIL RecPurcaseLine.NEXT=0; END;but even if field having value then also massage pop up and repeat infinite times as we close that massage
how i can wtite code so that it will work properly
thanks in advance.
0
Answers
-
better to use TESTFIELDS function thru EventsNow or Never0
-
but user want message pop up when field empty and for line level data of po how to do this?0
-
TESTFIELDS gives you pop up conditionally. And Events management helps you to achieve your goal without modifying the standard code.Now or Never0
-
When I tried testfield on post action it not showing field of line level of Purchase order such as type , No., Location Code,Descriptionline
TESTFIELD(Type); TESTFIELD(Location Code);
0 -
As others have mentioned, events are the best solution for this.
where have you placed the code from the original post? In codeunit 90? I think the reason you get the messages, even though the fields are filled, is because the rec where you have put your code is not the purchase document, but the posted document, which is being created.
If you setup an event as following:
Then you will have the Purchase Header Rec as VAR, and you can find the attatched lines.
0 -
I have put my code at POST action of purchase order page .so when user click on POST it will show error if any filed is empty. I don't know about event that much but by adding code also it should work I guess. but I don't clear how that code write so we get error message for empty field.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