0

How do I set a link after update?

Each Quote is associated with a Company which has Branches which have Contacts.

On the Quote form, I have a field where the user picks the company, then the Branch within that Company (validated to only show Branches associated with the above Company using b.Company.'Company Name' = a.Company.'Company Name') and then the Contact at that Branch, also validated to the Branch just picked above.

The problem is, if instead of just picking the Branch and Contact, the user creates a new Branch, that Branch's Company is not linked to the just created/picked Company for the Quote. As well, if they then go on to create a Contact, it is not linked to the just created/picked Branch.

I thought I could put some code in the Quote's Branch link field so that when it updates (e.g. picked or created new) it would set that Branch's Company to the Quote's Company (above). But I can't get it to work.

In the Quote's Branch field's "Trigger after update" I put this in:

Branch.Company = Company

Ostensibly thinking that the Quote's Branch's Company will now be set to the Quote's Company.

But that doesn't seem to work.

I know that the Trigger after update does trigger because if I have it set a text field on the Quote to some test text it does so.

What might I be doing wrong here?

3replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • (I mean Branch.Company := Company)

    Like
    • Fred
    • Fred
    • 2 mths ago
    • Reported - view
    Kent Signorini said:
    In the Quote's Branch field's "Trigger after update" I put this in:
    Branch.Company := Company

     What is not intuitive is what you wrote tells Ninox to make the Branch.Company equal to Branch.Company. Since it is Branch.Company is empty there is nothing to fill.

    Think of it this way. You have only made a reference to the link Branch so any references to field names will always be in reference to Branch. Unless the field name doesn't exist in Branch then Ninox will figure out what table it is in.

    You need to add the following to your code:

    let t := this;
    Branch.Company := t.Company
    

    We need to put the current record into a variable and then add the variable in front of Company. Now Ninox knows to make Branch.Company equal to what is in the current record Company.

    In fact when you click on New Record, the Company will be pre-filled. That was a nice surprise. I guess because clicking on New Record trips the Trigger after Update section of Branch.

    Like
    • Fred Fantastic! Thanks!

      Like
Like Follow
  • 2 mths agoLast active
  • 3Replies
  • 24Views
  • 2 Following