Updating other fields when a related field is updated in NAV Table designer

Hello, I have a table called Student with CustomerNo and CustomerName as fields from Customer Table. I want that when I update CustomerNo it causes CustomerName to get updated to match the name of the customer with the new CustomerNo. Thank you.

Best Answers

  • AlexeyShaminAlexeyShamin Member Posts: 80
    Answer ✓
    Hello!
    two ways:
    1. Create CustomerName as flowfield with calcformula Customer.No = CustomerNo
    2. Create function in table - RefreshName with code:
    IF Cust.GET(CustomerNo) THEN // Cust - record Customer
    CustomerName := Cust.Name
    ELSE
    CustName := '';

    Addcode on OnValidate trigger on CustomerNo field in table:
    RefreshName;
  • SsenyonjoSsenyonjo Member Posts: 2
    Answer ✓
    Thanks

Answers

  • AlexeyShaminAlexeyShamin Member Posts: 80
    Answer ✓
    Hello!
    two ways:
    1. Create CustomerName as flowfield with calcformula Customer.No = CustomerNo
    2. Create function in table - RefreshName with code:
    IF Cust.GET(CustomerNo) THEN // Cust - record Customer
    CustomerName := Cust.Name
    ELSE
    CustName := '';

    Addcode on OnValidate trigger on CustomerNo field in table:
    RefreshName;
  • SsenyonjoSsenyonjo Member Posts: 2
    Answer ✓
    Thanks
Sign In or Register to comment.