Automatically change a value when a date is equal to today
Hi, i need to change the state of a record when a date is equal to today. How can i trigger it?
5 replies
-
You can try something like this in a button:
if [date field] = today() then [field name] := [state] end
You would put the exact name of the date field and field name for [date field] and [field name] and your own value in place of [state]. Then everytime you clicked the button it will change the field to whatever you set it to.
Hope this helps.
-
Hi Fred,
First of all ty for your answer.
I need to do it without the button or any human interaction. Let's say today i change my state to "WAIT".
After 30 days if i didn't change it it should pass in "LATER". It's possible? If not, I could set a date when the state is changed but there's a trigger that works like a timer and don't need the human interaction?
-
Maybe you can try using the Trigger after open? You find this by clicking on the DB name, after you open it. Click on the red wrench. Click on Options.
To the best of limited knowledge there is no way to a chron like job in Ninox.
Then you need to change the code so it goes through the entire table, dending on your table size it could delay opening your DB.
Something like this:
for loop1 in Table1 do <-- opens a loop and grabs all records in Table1
let xDays := days(loop1.dateField1,today()) <--creates a variable that compares the number of days between your date field and today
if xDays >=30 then <--if the variable is equals to or greater than 30
loop1.([field name] := "Later")
end<--close the if statement
end<--close the for statement
For me, I always do these large modification triggers in a button first to make sure they do what I want. In addition, if you can grab a subset of records then you can modify the first line while you test out the code.
for loop1 select Table1 where field2 = "x" do
Good luck.
-
You could use a formula field to show the correct status rather than a choice Field, as formulas are calculated at the time the records are shown to the user.
If you physically want to trigger a change in the value of a field, without human interaction, this is a type of automation that needs to be done via the API. This could be achieved with Zapier/Integromat, or a custom script.
Feel free to reach out to me at https://danj.io and can help guide you through this!
Dan
Advanced Ninox Partner
-
Sorry for the late answer but thank you Fred, your solution works fine!!
Content aside
- 3 yrs agoLast active
- 5Replies
- 594Views