Validate sales line

kenlkenl Member Posts: 182
Hello,

I have a problem on validate sales line.
I need to avoid two sales lines having same Item and location code.

I add checking on Table SalesLine.OnInsert().

if condition Then
Error(Reason);

But when I run the form and hitting the condition, system will auto-close the form.

How do I do the checking?
I cann't put the checking on "No." and "Location Code" field level, since it would be too early to do checking.

Thanks.

Comments

  • charlpcharlp Member Posts: 21
    Hi kenl,

    I'm a novice in Navision, but I would do the following (on table level):

    In the OnValidate event of No., I would firstly check if the Location Code has already been supplied for this record. If it has, I will check if any other line items exist with the same combination. If none exist, add the record, else ERROR();

    In the OnValidate event of Location Code, I will check if the No. field has been filled. If it has, check for duplicates of this combination, same as above.

    Hope this helps.

    Cheers,
    Charl
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Search this forum for "Mandatory field(s)"

    You will find loads of information about how to create this.

    However, bottom line is, Navision does not like mandatory fields.

    Doing it the Navision way is easier. Check it in posting routines. Your users will get used to it.
  • kenlkenl Member Posts: 182
    Hello charlp,

    Thanks for your reply.

    As I said before, set the checking at field validate would be too early.

    Eg.
    If the user create line, fill in the same "No.", but leave "Location Code" blank, then the checking will be skipped.

    That 's why I need to put the checking at OnInsert().
Sign In or Register to comment.