Am still new in navision development I want to block a user from entering two same item number in the sales line this is because the user can inserts different quantities in the two lines in the same order number and two same item numbers want to have only one item number in the sales line not repeating the items number in the lines.Am using navision 2015.
You can achieve this as follows: on the sales line table, in the OnValidate trigger of the “No.” field, in the part where it says
CASE Type OF
…
…
…
Type::Item
You add this code:
//Start New Code >>
SalesLine.RESET;
SalesLine.SETFILTER(“Line No.”,’<>%1’,“Line No.”);
SalesLine.SETRANGE(“Document Type”,“Document Type”);
SalesLine.SETRANGE(“Document No.”,“Document No.”);
SalesLine.SETRANGE(“No.”,“No.”);
IF lrecSalesLine.FINDFIRST THEN
ERROR(STRSUBSTNO(‘Item No. %1 is already on this sales order.’,“No.”);
There are other ways around this problem. If you are using advanced warehousing you should look into bin ranking and sort the pick by bin rather than item if possible…
SalesLine2.RESET;
SalesLine2.SETFILTER(“Line No.”,’<>%1’,“Line No.”);
SalesLine2.SETRANGE(“Document Type”,“Document Type”);
SalesLine2.SETRANGE(“Document No.”,“Document No.”);
SalesLine2.SETRANGE(“No.”,“No.”);
IF lrecSalesLine2.FINDFIRST THEN
ERROR(STRSUBSTNO(‘Item No. %1 is already on this sales order.’,“No.”));
END;
just the same as u gave me first got an error lrecSalesLine2 NOT declared i declared as a boleen seems the code is not evaluating…
you can’t use a boolean field with FINDFIRST. I don’t wish to sound rude and we all started programming once, but with your current level of knowledge of C/AL, I think you can do a lot of damage in a client’s system. I recommend you study C/AL and work outside client systems while you are learning
I’m absolutely with [mention:cdef02f08d264a11ba032909f6995013:e9ed411860ed4f2ba0265705b8793d05] here. If you are using warehousing/picking then that’s the right place to enforce it.
The problem is so much that you change the code, but that you change, even if you know it will give problems down the road?
Did you consider Locations? What if one line is to come from one location and another from another location? That will beak the code. Or if variants are used, the same.
Consider all consequences, and present it as one to the customer. This one is way from over, even if it works for you now. It will come back and bite you, or at least the customer.
One of the big problems why so many customers is locked in their current versions, unable to upgrade (or pay the ransom), because their system has way too many changes they really didn’t need. Only because their consultant/developer never learned the system well enough to say or dared to say no. Sad to see - and that’s on a Friday afternoon. [emoticon:ca08b2c27c2f40e993e89508acf29e0b]
Erik, I’m not sure if your comment is directed at me or Masholeupao but anyway let me respond. I implemented this exact solution at a client who runs a large warehouse, with sales orders coming from various sources and it works fine. It is appropriate for their situation. It may not be appropriate for Masholeuapo’s exact needs but that is for him or her to decide. In my case, sales orders do not come from multiple locations and variants are not used. They use “chaotic” bin management (to call it something), so the products are not tied to one bin and can be found anywhere, so bin ranking is not appropriate. It has worked fine for years and has not come back to bite me. So if you are referring to me when you say the developer never learned the system - that is not a fair thing to say and I have been a developer since 2001. Chris