Hi all!
I'm trying to implement a new feature in NAV 2013. Basically this customer has promotions like for example if you buy 2 units of Item A you get one more unit for free.
The customer wants this "gift" unit to be a new sales line in the same order with unit price 0.
So I'm using something like the Sales Line discount functionality, that when the Quantity is modified, it automatically updates the %discount field is there is any promotion created, but in my case, I need to create a new line in stead.
I'm having some problems with this, because the Sales Line Table seems to be locked during validations, so I'm not able to create a new line.
So I guess I must create this new line after the validations are over and the table is unlocked.
Also another problem I'm having is that when I create a new line, all examples I've seen are something like:
SalesLine.VALIDATE(Quantity,Cantidad);
SalesLine.VALIDATE("Unit Price",Precio);
SalesLine.INSERT(TRUE)
But in this case the Unit Price is 0 and the Quantity doesn't need a validation, because otherways it would again create the gift Lines recursively.
Is there any problem with doing?:
SalesLine.Quantity := Cantidad;
SalesLine."Unit Price" := 0;
SalesLine.INSERT(TRUE);
Anyway I'm quite a newbie in NAV development, so I would like some advice on
where to place the code for my new line insert.
Thanks!