0

Constraint formula to prevent double

I have a table (Station) and a composit table (station composition). I also have another table (products). Inside Station table is some station name and inside station composition, I have a field linked to the station table (composit) and another linked field to product table.

So I can select a station and then select a product. I can have more than one entry per station (station 1 with product A, station 1 again with product 3...etc)

what i wish to do is add a constraint to the product field that if the product is already in the same station it wont be shown. Is it possible?

station      product

1               A

1              when i hit the field to select the product product A wont be in the list because station 1 have one.

2              A

Thanks!

3 replies

null
    • Jorg
    • 4 yrs ago
    • Reported - view

    Hi, 

    I think you should remove the 'station composition' table. Then Ninox would possibly automatically what you wish to do.

    To be sure about that, it would be the best to join our webinar and it would be nice if you could bring up your question there.

    Thank you very much.

    At our Ninox webinar tips and tricks will be presented in the first 30 minutes, the remaining 90 minutes will be used for a live support where the participants' concerns will be solved. 

    You can register here for the webinar, which takes place every Tuesday at 18 o'clock CEST: https://zoom.us/webinar/register/WN_zoSk2qyNSz6vLRFF1zlakg 

    Best regards, Jörg

    • Mconneen
    • 4 yrs ago
    • Reported - view

    Hmm.. Try this..   

    (1)  To the Station table... add a field called "Add Product", which is a relationship from Station to Product.   

    (2) In 'Add Product's Trigger after update ... put in the following code..   basically .. we are create a search / add field.. then clearing it out at the end. 

    trigger

    (3)  In 'Add Product's Constraints ... put in the following code:  we are counting the number of times that the Product is constained within the Station's 'Station Composite' table.   and we want that number to be ZERO. 

    constraint

    Here is a snapshot of what it should look like

    addProduct

    station

    • BlancoLandau
    • 4 yrs ago
    • Reported - view

    Hi Mconneen,

    Why should it ZERO in the point 3 (  cnt(...) = 0    )

     

    Thanks.

    Jaime

Content aside

  • 4 yrs agoLast active
  • 3Replies
  • 1852Views