Dynamic Date field not updating

Any critical bugs will be fixed within 24-48 hours.
Post Reply
Eddy
Posts: 121
Joined: 28 Dec 2017, 03:38
Name: Eduardo
Location: UK

Dynamic Date field not updating

Post by Eddy »

Good morning,

I have an entity with several Dynamic Date Fields (red in fig1) and the data for these fields come from a query formula. It works well the first time the record is created or when a record is open and saved again. Fig 2 shows what happens with record JobID 693 after opening it for edit and then just saving it without changing anything. The information was there as shown by record JobID 654 but it will not be updated/shown unless I open the record for editing and save it again.

It looks like the query formula is only run when the record is created or when it is saved again after edit. The problem is that if the date is updated in the entity that is used/searched by the dynamic date field query these changes are not passed on for the table list report to show correctly.

Please help.
fig1.png
fig2.png
User avatar
support
Site Admin
Posts: 6231
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Dynamic Date field not updating

Post by support »

Not clear how to reproduce. Create simple example and give me the steps to reproduce it.
Eddy
Posts: 121
Joined: 28 Dec 2017, 03:38
Name: Eduardo
Location: UK

Re: Dynamic Date field not updating

Post by Eddy »

A fresh installation of 2.9 (without restoring my database), only adding the required fields to check for the issue, is working okay. I am going to move back to 2.8.3 to see if the problem was also there and didn't noticed. I will post back soon.

Thanks
Eddy
Posts: 121
Joined: 28 Dec 2017, 03:38
Name: Eduardo
Location: UK

Re: Dynamic Date field not updating

Post by Eddy »

Okay, I am making very little progress with this one. Three points:

1) The Dynamic Date field no refresh issue only happens with the Admin user account. All the other accounts that I have tried are okay??

2) Trying to restore a backup databases (two different backups from before update) using a fresh installation of 2.8.3 is giving me this error at login. Please note /old referrers to the directory where I installed the fresh version of 2.8.3 (bad name selection, but hey was only to check!)

Database Error: 1418 - This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
Query: CREATE FUNCTION `rukovoditel_days_diff`(`start_date` INT, `end_date` INT, `exclude_days` VARCHAR(64), `exclude_last_day` TINYINT(1), `exclude_holidays` TINYINT(1)) RETURNS int(11) BEGIN DECLARE days_diff INT; DECLARE inc_days TINYINT; SET days_diff=0; IF start_date>0 and end_date>0 and end_date>=start_date THEN #skip while if no restriction IF length(exclude_days)=0 and exclude_holidays!=1 THEN SET days_diff = (end_date-start_date)/86400; IF exclude_last_day!=1 THEN SET days_diff = days_diff+1; END IF; RETURN days_diff; END IF; WHILE FROM_UNIXTIME(start_date,'%Y-%m-%d')<=FROM_UNIXTIME(end_date,'%Y-%m-%d') DO SET inc_days=1; #exclude day of week IF find_in_set(DAYOFWEEK(FROM_UNIXTIME(start_date,'%Y-%m-%d')),exclude_days) THEN SET inc_days=0; END IF; #exclude last day IF exclude_last_day=1 and FROM_UNIXTIME(start_date,'%Y-%m-%d')=FROM_UNIXTIME(end_date,'%Y-%m-%d')THEN SET inc_days=0; END IF; #exclude holidays IF exclude_holidays=1 THEN SET @start_date_var = FROM_UNIXTIME(start_date,'%Y-%m-%d'); SET @is_holiday = (select count(*) from app_holidays h where h.start_date<= @start_date_var and h.end_date>=@start_date_var); if @is_holiday!=0 THEN SET inc_days=0; END if; END IF; IF inc_days=1 THEN SET days_diff =days_diff+1; END IF; SET start_date = start_date+86400; END WHILE; END IF; RETURN days_diff; END;
Page: /old/index.php?module=tools/db_restore_process&action=restore_file

3) Again, using a fresh install of 2.8.3 and restoring the database via phpMyAdmin gets me pass login but when trying to read the projects I get this error.

Database Error: 1305 - FUNCTION old.rukovoditel_days_diff does not exist
Query: select e.* ,rukovoditel_days_diff(e.field_171,1624348415,'','','') as field_385 from app_entity_22 e where e.id>0 and e.parent_item_id in (select item_id from (select e.id as item_id , ( (select count(*) from app_entity_22 func100 where func100.id>0 and (func100.field_169 in (12) ) and func100.parent_item_id=e.id ) ) as field_357, ( (select count(*) from app_entity_22 func100 where func100.id>0 and (func100.field_169 in (10) ) and func100.parent_item_id=e.id ) ) as field_358, ( (select count(*) from app_entity_22 func100 where func100.id>0 and (func100.field_169 in (13) ) and func100.parent_item_id=e.id ) ) as field_359, ( (select count(*) from app_entity_22 func100 where func100.id>0 and (func100.field_169 in (12) ) and func100.parent_item_id=e.id ) + (select count(*) from app_entity_22 func100 where func100.id>0 and (func100.field_169 in (10) ) and func100.parent_item_id=e.id ) + (select count(*) from app_entity_22 func100 where func100.id>0 and (func100.field_169 in (13) ) and func100.parent_item_id=e.id ) + (select count(*) from app_entity_22 func100 where func100.id>0 and (func100.field_169 in (34) ) and func100.parent_item_id=e.id ) ) as field_361, ( (select count(*) from app_entity_22 func100 where func100.id>0 and (func100.field_169 in (34) ) and func100.parent_item_id=e.id ) ) as field_401 from app_entity_21 e where e.id>0 ) as parent_entity_21 ) order by e.id desc limit 0, 30
Page: /old/index.php?module=items/listing

I don't think to be doing anything particularly wrong and can't go back to 2.8.3 to check if this issue was there before update.
User avatar
support
Site Admin
Posts: 6231
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Dynamic Date field not updating

Post by support »

rukovoditel_days_diff is function that autocreate when you create/edit field days_diff
So try to edit field with type days_diff and see if this function is created.
If not you will see an error.
Eddy
Posts: 121
Joined: 28 Dec 2017, 03:38
Name: Eduardo
Location: UK

Re: Dynamic Date field not updating

Post by Eddy »

I couldn't edit the field, so I deleted it and tried to recreate it. In both cases, edit and creating a new one, I get this error on the create/configure field form (also in picture for clarity). Moreover, the project's list is shown okay when I delete the days_diff field and, to my surprise, the Dynamic Date field query is not updating either in 2.8.3 but only for the admin user. All other users are okay.

Database Error: 1418 - This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
Query: CREATE FUNCTION `rukovoditel_days_diff`(`start_date` INT, `end_date` INT, `exclude_days` VARCHAR(64), `exclude_last_day` TINYINT(1), `exclude_holidays` TINYINT(1)) RETURNS int(11) BEGIN DECLARE days_diff INT; DECLARE inc_days TINYINT; SET days_diff=0; IF start_date>0 and end_date>0 and end_date>=start_date THEN #skip while if no restriction IF length(exclude_days)=0 and exclude_holidays!=1 THEN SET days_diff = (end_date-start_date)/86400; IF exclude_last_day!=1 THEN SET days_diff = days_diff+1; END IF; RETURN days_diff; END IF; WHILE FROM_UNIXTIME(start_date,'%Y-%m-%d')<=FROM_UNIXTIME(end_date,'%Y-%m-%d') DO SET inc_days=1; #exclude day of week IF find_in_set(DAYOFWEEK(FROM_UNIXTIME(start_date,'%Y-%m-%d')),exclude_days) THEN SET inc_days=0; END IF; #exclude last day IF exclude_last_day=1 and FROM_UNIXTIME(start_date,'%Y-%m-%d')=FROM_UNIXTIME(end_date,'%Y-%m-%d')THEN SET inc_days=0; END IF; #exclude holidays IF exclude_holidays=1 THEN SET @start_date_var = FROM_UNIXTIME(start_date,'%Y-%m-%d'); SET @is_holiday = (select count(*) from app_holidays h where h.start_date<= @start_date_var and h.end_date>=@start_date_var); if @is_holiday!=0 THEN SET inc_days=0; END if; END IF; IF inc_days=1 THEN SET days_diff =days_diff+1; END IF; SET start_date = start_date+86400; END WHILE; END IF; RETURN days_diff; END;
Page: /old/index.php?module=entities/fields_configuration
fig.png
User avatar
support
Site Admin
Posts: 6231
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Dynamic Date field not updating

Post by support »

This is issue with your server configuration. See https://stackoverflow.com/questions/260 ... -logging-i
Eddy
Posts: 121
Joined: 28 Dec 2017, 03:38
Name: Eduardo
Location: UK

Re: Dynamic Date field not updating

Post by Eddy »

Thanks, restoring backups and diff_date now works. I am still puzzle by the Dynamic Date field issue (list of projects with Dynamic Date field not updating for admin user, unless I open each record and save it again) but at least it is not affecting the other system users. I will report back if I stumble on the answer for this one.
Post Reply