Update a field value if another field's value has been changed

Hello.

How can I change a field's value in Table 2 based on the condition that another field's value in Table 1 has been changed? One has to update the other. And same with emptying or deleting the field. Any code examples?


Thanks in advance.

Best Answer

Answers

  • LefteyedLefteyed Member Posts: 43
    Table 1:
    Field - OnValidate:

    // Filter to get the right record to changes in table 2
    // your filter -

    // Change value
    Table2.VALIDATE(Field, Value);
    Table2.MODIFY(TRUE);
  • siimsandsiimsand Member Posts: 28
    Lefteyed wrote: »
    Table 1:
    Field - OnValidate:

    // Filter to get the right record to changes in table 2
    // your filter -

    // Change value
    Table2.VALIDATE(Field, Value);
    Table2.MODIFY(TRUE);

    Thank you. But how can I empty a record in table 2 if a field has been emptied in table 1?
  • lubostlubost Member Posts: 628
    Emptying record is wrong way. If you deleting record from Table 1, you can use OnDelete trigger to delete record(s) in Table 2 (same way as Lefteyed wrote.
    If it is 1:1 relationship between Table 1 and Table 2, you should use only one table with merged columns.
Sign In or Register to comment.