Validate Combination

erugalatha
erugalatha Member Posts: 120
Hi,

I have a new table. When entering a new line on this table I need to (in OnValidate) check if the combination of Sales Doc. No. and Carton No. exists on other lines and if it does then verify that Carton Types is consistent.

How do I check if the combination exists on other lines?

Thank you.

Answers

  • kine
    kine Member Posts: 12,562
    Something like:
    MyRec.SETRANGE("Carton No.","Carton No.");
    MyRec.SETFILTER("Carton Type",'<>%1',"Carton Type");
    MyRec.SETRANGE("Sales Doc. No.","Sales Doc. No.");
    if not MyRec.ISEMPTY then
      Error(....)
    

    (find line for same Sales Doc. No and Carton No. but with different Carton type - if found, it is error)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.