Validation of on same item no. used on Sales Order
liizz
Member Posts: 125
Hello,
I want to add a validation on the Sales line on the Sales Order form whereby it checks that the same item no. is not being used on lines.
No.-OnValidate
SalesLine.SETRANGE(No.,No.);
IF SalesLine.FINDFIRST THEN
ERROR('Same item no. cannot be used more than once');
But, even after picking a new item, it is passing into the above codes. I think the item no. should be immediately cleared out after prompting the error message.
Your help is very appreciated..
Liizz
I want to add a validation on the Sales line on the Sales Order form whereby it checks that the same item no. is not being used on lines.
No.-OnValidate
SalesLine.SETRANGE(No.,No.);
IF SalesLine.FINDFIRST THEN
ERROR('Same item no. cannot be used more than once');
But, even after picking a new item, it is passing into the above codes. I think the item no. should be immediately cleared out after prompting the error message.
Your help is very appreciated..
Liizz
0
Comments
-
Please show us the real C/AL code. This one won't compile.
The Item No. is stored in the field "Item No." of the Sales Line table, not the field "No.".
EDIT: You should also filter on Document Type and Document No.No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
Luc Van Dyck wrote:The Item No. is stored in the field "Item No." of the Sales Line table, not the field "No.".
are you sure?
David Singleton0 -
Nope, don't know what happened to meDavid Singleton wrote:are you sure?
No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
Its No. in the Sales Line table which lookup in the Item list.
Document Type Document No. Line No. Type No.
Order 1001 10000 Item 1928-W0 -
Luc Van Dyck wrote:The Item No. is stored in the field "Item No." of the Sales Line table, not the field "No.".
Its ok about it.
Is there a possible way to clear out the field automatically after the error message.
Liizz0 -
What do you need to clear this field it should work fine without clear the field. where you have written the code to check duplicate item?0
-
I have written the code on this trigger:No.-OnValidate.
It is checking for duplicate items but the Item No. should be cleared after the error message. Instead of deleting the item no. manually.
Thanks
Liizz0 -
We do it like this:
No. - OnValidate() //Item can only show up once per SO SalesLineChk.SETCURRENTKEY("Document Type", "Document No."); SalesLineChk.SETRANGE("Document Type", "Document Type"); SalesLineChk.SETRANGE("Document No.", "Document No."); SalesLineChk.SETRANGE(Type,SalesLineChk.Type::Item); Existed := FALSE; //Add Setup Boolean to turn on and off service SalesSetup.GET; IF SalesSetup."Enable Duplicate Item Dialog" THEN BEGIN //check if already exists not on returns or credits IF NOT ("Document Type" IN ["Document Type"::"Return Order","Document Type"::"Credit Memo"]) THEN BEGIN IF SalesLineChk.FIND('-') THEN REPEAT IF SalesLineChk."No." = "No." THEN IF NOT CONFIRM ('Item Already on order. Do you want to add item again?') THEN BEGIN MESSAGE('Item disregarded.'); "No." := ''; SalesLineChk.NEXT := 0; END ELSE Existed := TRUE; UNTIL (SalesLineChk.NEXT = 0) OR Existed; END; END;
C/AL Locals: (Variables)
SalesLineChk - Record - Sales Line
Existed - Boolean0 -
The OnValidate trigger of the form or the table? This needs to be in the TABLE.liizz wrote:I have written the code on this trigger:No.-OnValidate.0 -
On my code it is on the No. - OnValidate() of the sales line table.
We've made it so it only looks at ITEM types incase you need to add more than one comment line or g/l.
Also it allows duplicates on credit memo's & return orders because we use two locations(Active & Damaged)
so if a customer returns 10 pieces... 5 good & 5 bad we enter the item 2x
item 123 - pcs 5 - location damaged
item 123 - pcs 5 - location active
you have to make sure your not affecting other types of orders, that the sales line table handles, that you like they way they are working.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions


