0

Triggers

I need to have a date field that calculates 342 days added on to ‘breeding’ date entered in a table -

So if someone enters 1/1/2016 for a breeding date

I need the foaling date to show: 12/8/2016 (342 days later)

32 replies

null
    • Alexander_Koenig
    • 8 yrs ago
    • Reported - view
    Hi, you can do so with a formula field and type in the formula editor: Date + 342.
    Best regards, Alex
    • mydanes
    • 8 yrs ago
    • Reported - view
    another question I am using a trigger to populate this date for me but because it is an 'after' update it demands that i click on the date and then it does my calculation is there a way for the trigger to fire without the user having to touch that field? can it update when the 'record' is effected but not that specific column?
    • Frank_Bohmer
    • 8 yrs ago
    • Reported - view
    There are also triggers which act on record level - i.e. every time some data field in the record changes. Have a look at the left pane of the table defintion. There's an option "Trigger after update".
    • GospelTheGrey
    • 7 yrs ago
    • Reported - view
    Does the table level update trigger execute before or after a field level level update triggers execute for a given row? My guess would be after. Thanks!
    • Frank_Bohmer
    • 7 yrs ago
    • Reported - view
    Hi GospelTheGrey,
    good question! And you're right. First the field level trigger will execute, then the table level trigger.
    Best regards
    Frank
    • CISOFT_Sarl
    • 7 yrs ago
    • Reported - view
    Is it possible?
    I have a table with locations, more than 5000, and I would like a way to be able to display the table with a filter to select only one of the filter records.
    thank you in advance
    Robert
    • Alexander_Koenig
    • 7 yrs ago
    • Reported - view
    Hello Robert,

    you can use filters in a table. Click on the column head (where the name is written) and apply a filter. If there are questions, you can also drop a line to support@ninoxdb.de

    Best regards, Alexander
    • svkarvi
    • 6 yrs ago
    • Reported - view
    Field update trigger problem:

    If a Yes/No (checkbox) field is set to "Yes", I want to update Time field with the time the field is updated with the value "Yes". If the same field is set to "No", I want to clear the time field. I'm using the following trigger:

    if (Checkbox := true) then
    ('Contact Time' := now())
    else
    ('Contact Time' := null)

    There isn't an option to clear a time field, so I've tried null and "".

    In any case, I am able to check the field and the 'Contact Field' updates correctly. The Yes/No (checkbox) field cannot then be updated again back to a "No" condition under any circumstances unless the triggeer is deleted. What am I doing wrong, and how can I "clear" a time or date/time field?

    Ninox v2.0.3
    OS: IOS 10.3
    Hardware: iPad Pro

    Thanks.
    • Leonid_Semik
    • 6 yrs ago
    • Reported - view
    Hi,
    In the first line you must write

    "if (Checkbox = true) "

    Not "if (Checkbox := true) "

    Regards
    Leo
    • svkarvi
    • 6 yrs ago
    • Reported - view
    Thanks so much. Duh! It's been a few years since I've done any programming. I had forgotten := is assignment, = is a logic test. The trigger worked with just the logic test "if checkbox". Thanks again.
    • Christoph.1
    • 6 yrs ago
    • Reported - view
    Hi Ninox team!

    Is there a possibility to automatically populate a field with information fetched from a file path or from an external url?

    Example:
    I enter a person ID into field "PersID". Based on that entry, I can calculate an URL to a photo of that person like this "http://my.company.com/api/persons/" + Pers_ID + "/picture". Alternatively, I could work with a calculated path to a folder on my local hard disk where all picture files are stored with a name in the form "PersID.jpg".

    I hoped that I can set a trigger to the field "PersID" that then populates various other fields of the same record from local or web-based resources as described above. So far, I only managed to populate other fields with links to external data, but not with the actual external data.

    Is it possible at all to do what I want in Ninox? If yes: How? If no: Are there plans to add such functionality? Thanks in advance & kind regards, Christoph
    • Birger_H
    • 6 yrs ago
    • Reported - view
    Hello, this should be easy :-)
    Say you have a field "Pers_ID" and URL field "URL".
    Use the trigger "onChange" in the field "Pers_ID" to set the URL like this:
    –––
    URL := "http://my.company.com/api/persons/" + Pers_ID + "/picture"
    –––


    Birger - Ninox Support
    • Christoph.1
    • 6 yrs ago
    • Reported - view
    Hi Birger, thanks for the quick reply!

    Sorry, I wasn't clear enough with my question. I'm already using what you describe above for URL fields, and that works fine. But I would like to go one step further.

    For example, I have an Image field "Photo". Now I tried to set a trigger on the field "Pers_ID" like this:
    Photo := "http://my.company.com/api/persons/" + Pers_ID + "/picture"
    to automagically load the picture after I entered the Person ID. But when I do this, my Image field "Photo" just contains the text of the URL, but not the picture.

    What I would like to do would probably require a function like DOWNLOAD(URL) or EVAL(URL) or GET(URL), and then the trigger could be Photo := DOWNLOAD("http://my.company.com/api/persons/" + Pers_ID + "/picture" ). And ideally, this would work with URLs and local hard disk paths.

    I haven't found anything like this in the reference of functions, so I fear it's not currently possible to do what I wanted. But maybe I overlooked something, or maybe this could be a future extension? It would be extremely helpful for applications where Ninox is used to dynamically combine existing data from an external source (read-only) with own data fields.
    • Birger_H
    • 6 yrs ago
    • Reported - view
    Here is a solution:


    Greeting
    Birger - Ninox Support
    • Christoph.1
    • 6 yrs ago
    • Reported - view
    Hi Birger

    Wow, this is pretty cool. I haven't been aware that this is possible with formulas.

    After testing it, I see one drawback and one issue:
    The drawback: With my trigger attempt I hoped to be able to load the image data into Ninox when adding a new record, so that the photo is also displayed when I'm not online later (after initial download). This is not possible with the formula approach; i.e. to see the photo you have to always be online.
    The issue: For some reason that I don't currently understand, it only works for the first 6 photos. I relaunched Ninox several times and tried it with different records. It was always the same: For the first 6 records I opened, the photo was displayed ok, and after that the formula field remained blank. I tried the same with a browser to make sure it's not a server-side limitation, and I didn't see the problem there. 6 photos roughly correspond to 0.5 MB of data; does this exceed the capacity of some local cache or so?

    Kind regards,
    Christoph
    • Birger_H
    • 6 yrs ago
    • Reported - view
    Hi Christoph, you are right: The formula approach will only work if the device is online. Pictures are not downloaded. The problem is that in the OSX enviroment Apps don't have access to the file system.

    Regarding the second topic "only the first 6 photos"... If you could send me a copy of the Ninox database you are working on (Main menu -> "Save Archvie as...") I'm sure that I can find a solution to your problem. My mail address: support@ninoxdb.de

    Birger - Ninox Support
    • ruimnasa
    • 6 yrs ago
    • Reported - view
    I have defined a trigger "after update", and it works fine when I change a record directly.
    But, when I import data to populate several records, it does not work. Am I missing anything in the configuration ?

    Thanks in advance,

    Rui
    • Birger_H
    • 6 yrs ago
    • Reported - view
    Triggers will not execute when importing data. Please give the formula to the import assistant or change the data using "Mass data update..."

    Birger - Ninox Support
    • ruimnasa
    • 6 yrs ago
    • Reported - view
    Thanks for the information.

    I tried other option thats works for me. I added a button that triggers the updating code, for all the new records, after loading data from the file.

    Regards,

    Rui
    • Ivan_Savochenko
    • 6 yrs ago
    • Reported - view
    Hi, Does there a way to style a field basing on entered data?

    I mean: I want to check entered data and warn user if one has misspelled. And I don't want to create any additional field for that.
    • Birger_H
    • 6 yrs ago
    • Reported - view
    Have a look at this small example:


    The formular is:
    styled(Text, "warn", if Number < 0 then "red" else "black" end, "blue")

    Birger - Ninox Support
    • Dominik_Eng
    • 6 yrs ago
    • Reported - view
    Sorry aber müsste es nicht so aussehen:
    styled(Text, "yellow", if Number < 0 then "red" else "black" end, "warn")
    • codavlas
    • 6 yrs ago
    • Reported - view
    Sorry for my very basic question:

    I have a table called Customers with a subtable called Orders.

    And Orders has a subtable called Order Lines. This subtable has a field called Position, that it is some kind of line counter.

    I’ve set up a table level trigger on create on Order Lines:

    Position := max((select 'Order Lines').Position) + 1

    If I create a first Order for a Customer, it works fine. First Order Line is created with Position 1, and the second one with 2.

    But if I create a second Order, the Position field for the first Order Line is created with 3 instead of 1.

    I guess that something is missing on the trigger, but I do not know what is it.

    Can you please help?

    Thank you
    • Birger_H
    • 6 yrs ago
    • Reported - view
    Try it like this:
    –––
    let myOrder := Order._id;
    Position := max((select 'Order Lines' where Order._id = myOrder).Position) + 1
    –––


    Birger - Ninox Support
    • Holzi
    • 6 yrs ago
    • Reported - view
    Yes, that's the right way.
    Another example:
    styled(Text, if Number < 0 then "yellow" else "white" end, if Number < 0 then "red" else "black" end, if Number < 0 then "warn" else "ok" end)

Content aside

  • 6 yrs agoLast active
  • 32Replies
  • 15772Views