0

How to update a field with a lookup value from another table?

In the image above, I have selected an employee from the Employee table via pop-up. 

Now, however, I want to populate the "emp_fk" field in the Tasks table with the Employee's "emp_pk" field from the Employee table (after we selected the Employee name).

I realize this population isn't necessary to have Ninox work correctly, but I'm trying to understand how to do this population for other cases like this.

I was thinking that when the user selects the Employee name from the pop-up (middle field above) from the Employee table, I'd set the emp_fk field above in the Tasks table using a formula something like:

Employee.Task.emp_fk = (select Employee).emp_PK

See below: this "trigger after update" doesn't do anything after the selection.

I also tried to add a where, but could not get that to work or find documentation other then "coming soon" in the documentation...

So, how would I update a field in the tasks table using a lookup from the Employee table after the user selects the employee name?

Thanks,

5 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 2 yrs ago
    • Reported - view

    By placing a := instead of a =

    := is used to assign a value to a field or variable

    = is to compare two values.

      • ninox.1
      • 2 yrs ago
      • Reported - view

      RoSoft_Steven Rooryck That is helpful, but it now says it's returning multiple values. I'm trying to add a WHERE clause (like in SQL), but it's not working. Suggestions?

      • ninox.1
      • 2 yrs ago
      • Reported - view

      Mike I think I got it. Thanks RoSoft_Steven Rooryck ! :)

      • Ninox partner
      • RoSoft_Steven.1
      • 2 yrs ago
      • Reported - view

      Mike You need only:

      emp_fk := Employee.emp_PK

      in the trigger after update of your Employee - selection field.

    • Fred
    • 2 yrs ago
    • Reported - view

    Now that you learned the trigger method with Steven, another way of doing this would be to make emp_fk a formula field and put this in the formula:

    Employee.emp_PK

    Now it will be whatever emp_PK is when you select the Employee in the reference field. So now you can call emp_fk in future codes without going to Employee.emp_PK.

Content aside

  • Status Answered
  • 2 yrs agoLast active
  • 5Replies
  • 488Views
  • 3 Following