Script or filed calculations to add years to a date field

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
nandrew
Posts: 5
Joined: 2019-10-16 12:24

Script or filed calculations to add years to a date field

Post by nandrew » 2019-10-22 14:31

Hello,
I have an AppGini project I am using for record storage. I want the destroy date to calculate automatically by calling the date entered for the box packed date and adding the number of years to retain. I have a date select box for both the packed and destroy date and a drop down list of numbers to select the years to retain the box. I would also like the destroy date to change to permanent if it is selected from the retention drop down instead of a year.

packed date + retention years = destroy date
if permanent selected from drop down list instead of a year, display "permanent" instead of destroy date

Thanks,
Neil

I have added a picture of the add a box page:
Image

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Script or filed calculations to add years to a date field

Post by pbottcher » 2019-10-22 19:10

Hi,

can you post what you have as code so far. Also, are the packed date and destroy date text fields where you enter the date manually? They do not look like datepicker fields. At least the packed date should be a datepicker.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

nandrew
Posts: 5
Joined: 2019-10-16 12:24

Re: Script or filed calculations to add years to a date field

Post by nandrew » 2019-10-23 22:23

I changed the packed by field to a date picker. I thought it might be possible to use the calculated field area in appgini. I was just trying to get the date add part working first. The destroy date box could either show "permanent" or be hidden because the retention drop down box would display "permanent" already. I tried adding the following sql query to the "destroy date" field.

SELECT IF(
DATE_ADD(year, 'retention',`packed_date`)As DATE_ADD;
)

Image

Post Reply