0

reset/unlink client field (field a) when advicor (field b) is removed

Hi everyone,

I have a form with two relationship fields in Ninox:

  1. Advisor (1:N): Allows selecting one or more advisors.
  2. Client (N:1): Allows selecting a client who is being advised by the chosen advisor(s).

The Problem:
The "Client" field should only be editable if at least one advisor is selected (I’ve already handled this with write permissions). However, if a client is selected and then the advisor is unlinked/removed, the client remains in the field. Instead, I want the "Client" field to automatically reset (become empty) as soon as no advisor is selected.

I tried using an if statement in a formula field and/or as trigger (tried table advisor and the field client, both didn't work):

if (Advisor = null and Client != null) then
    Client := null
end

How can I automatically clear the "Client" field when no advisor is selected? Is there a way to achieve this with a trigger, formula, or script?

3 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 4 days ago
    • Reported - view

    Don't use Client:=null but use Client:=0

      • Samuel_Kasper
      • 3 days ago
      • Reported - view

       
      i fixed my code and it works if i use a button

      if number(advisor) = 0 then
          Client :=  0
      end

      but i can't manage to trigger the event without pushing a button. what i want: 
      - if i unlink the linked advisor, any linked client should be unlinked too 

      problem: a trigger after doesn't work
      - for the relational field client
      - for the relational field advisor (its not possible to set a trigger for this field)
      - for the whole form

      if i use the trigger in my table advisors on the other side of the relational field advisor, the trigger works. but only when i unlink an old and link a new advisor -> any linked clients are unlinked
      but i want them to be unlinked as soon as i unlink the advisor (and not as i switch advisors)
       

      • Fred
      • 3 days ago
      • Reported - view

       Looks like you are limited to using a button if you want to continue with this data model. The 1 side limitations (no triggers and doesn't register as an action on the record) are keeping you from doing what you want.

Content aside

  • 3 days agoLast active
  • 3Replies
  • 31Views
  • 3 Following