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.
Why is the user entering two lines with the same item code but different quantities a problem for you?
Removing/Blocking the ability to do this could cause issues further down the line i.e. adding a line on a Sales Order that has been shipped out…
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
You add this code:
//Start New Code >>
SalesLine.SETFILTER(“Line No.”,’<>%1’,“Line No.”);
SalesLine.SETRANGE(“Document Type”,“Document Type”);
SalesLine.SETRANGE(“Document No.”,“Document No.”);
IF lrecSalesLine.FINDFIRST THEN
ERROR(STRSUBSTNO(‘Item No. %1 is already on this sales order.’,“No.”);
//End New Code <<
Where SalesLine = a variable for table record 37
Hope this helps
One of my clients uses this modification too - it is to so pickers in the warehouse are not sent to look for the same item twice during a long pick.
Yes the same scenario where the dispatch team only pack one of the items and forgets other
will try this and get back tommorrow thanks alot
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…
want to block as sales order level when one is raising an order
I understand, you want to do this to prevent problems at the picking stage that’s why I made the above suggestion… Just a suggestion
have put begin to end but there is still errors on this lines of code
error I get the error "“A value or expression was expected.” For example
myvar = 100
Please post all the code you’ve got in the OnValidate trigger of the “No.” field
SalesLine2.SETFILTER(“Line No.”,’<>%1’,“Line No.”);
SalesLine2.SETRANGE(“Document Type”,“Document Type”);
SalesLine2.SETRANGE(“Document No.”,“Document No.”);
IF lrecSalesLine2.FINDFIRST THEN
ERROR(STRSUBSTNO(‘Item No. %1 is already on this sales order.’,“No.”));
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…
My mistake sorry - change lrecSalesLine2 to SalesLine2 - it is all the same variable. Have you done any C/AL programming training?
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
yes thanks a lot for the advice actually am doing all this on my learning/test database thanks for the advice
ok that’s great. Is the code working now?
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